【问题标题】:Python iptables matches (uid-owner) errorPython iptables 匹配(uid-owner)错误
【发布时间】:2017-07-11 20:02:07
【问题描述】:

我正在尝试使用 python-iptables 库创建以下规则。

  # iptables -t nat -A OUTPUT -p tcp -m owner --uid-owner username -j DROP

这是我的代码

chain = iptc.Chain(iptc.Table(iptc.Table.NAT), "OUTPUT")
rule = iptc.Rule()
rule.protocol = "tcp"
match = iptc.Match(rule, "owner")
match.uid_owner = "username"
rule.target = iptc.Target(rule, "DROP")
rule.add_match(match)

我收到以下错误

    match.uid_owner = "username"
  File "/usr/lib64/python2.7/site-packages/iptc/ip4tc.py", line 455, in __setattr__
    self.parse(name.replace("_", "-"), value)
  File "/usr/lib64/python2.7/site-packages/iptc/ip4tc.py", line 332, in parse
    self._parse(argv, inv, entry)
  File "/usr/lib64/python2.7/site-packages/iptc/ip4tc.py", line 600, in _parse
    self._orig_parse, self._orig_options)
  File "/usr/lib64/python2.7/site-packages/iptc/xtables.py", line 856, in new
    return fn(*args)
  File "/usr/lib64/python2.7/site-packages/iptc/xtables.py", line 1155, in parse_match
    m.name, len(argv) > 1 and argv[1] or "", rv))
iptc.xtables.XTablesError: owner: parameter 'username' error -2

如何使用这个库添加这样的规则?

【问题讨论】:

    标签: python python-2.7 iptables python-iptables


    【解决方案1】:

    问题已解决,问题是用户名不正确

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-27
      • 2019-05-14
      • 2017-01-23
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      相关资源
      最近更新 更多