【发布时间】:2021-05-28 09:19:24
【问题描述】:
这是我用于调用 IPtables 的 python 脚本,我需要 SQLite 输出来制定规则 (df2)
subprocess.run(["/usr/sbin/iptables", "-A", "INPUT", "-p", "udp", "-m", "udp", "--dport 5060", "-m" "string",
"--string" , "/home/as/Documents/mydf.csv", "-algo", "bm", "--to 655535", "-j" ,"REJECT"])
我遇到的错误
iptables v 1.8.4v(legacy): unknown option --string
【问题讨论】:
-
"-algo bm"需要是两个字符串:"-algo", "bm"。与"--to 65535"相同。 iptables 的路径错误,所以这不是你的确切代码。 -
...和
"--dport 5060" -
@TimRoberts 我也试过分离所有的字符串,但没有运气,也请你告诉我如何写路径位置,我写路径为
subprocess.call(["/usr/sbin/iptables"(iptable file location),..(all the middle strings separated by " ")....,"/home/Documents/.csv(file location)"]) -
@larsks 我尝试分离所有字符串
-
我的意思是,在您问题的示例中,您的“usr/bin/iptables”没有前导斜杠。您是否安装了 iptables-string 扩展?为什么在 Linux 系统中使用 Windows 文件路径?
标签: python bash subprocess iptables