ldx / python-iptables

Python bindings for iptables
730 stars 182 forks source link

rules dont seem to apply #314

Closed dogasantos closed 3 years ago

dogasantos commented 3 years ago

Hey there, i'm testing this library and for some reason it doesn't seem to be working on my case. I'm not sure if I'm missing something or it's a compatibility with python 3.8, here is the snippet:

` import iptc

rule = iptc.Rule() rule.protocol = "tcp" match = iptc.Match(rule, "tcp") rule.add_match(match) rule.src = "192.168.86.86/255.255.255.255" rule.target = iptc.Target(rule, "ACCEPT") rule.in_interface = "+" match = rule.create_match("comment") match.comment = "managed rule created by iptc" table = iptc.Table(iptc.Table.FILTER) chain = iptc.Chain(table, "INPUT") chain.insert_rule(rule) table.commit()`

It doesn't throw any error, I can see the rule in chain.rules, but this rule is not actually applied. Can't see the rule using iptables -n -L either.

Any advice? thanks!

ldx commented 3 years ago

What version of iptables do you have installed? Recent operating system versions use nftables, and iptables is just a wrapper around it.

Does using iptables-legacy to check your rules work and show the rule you added?

dogasantos commented 3 years ago

Hi, thanks for your repply. Yes, you're right, it's on legacy iptables. Thanks!!