ldx / python-iptables

Python bindings for iptables
730 stars 182 forks source link

query icmp ype from rule #310

Open dmzoneill opened 4 years ago

dmzoneill commented 4 years ago

Hi,

I have the following rules:

ACCEPT icmp -- 10.246.0.0/16 10.255.253.4 icmptype 8 state NEW,RELATED,ESTABLISHED ACCEPT tcp -- 10.246.0.0/16 10.255.253.4 tcp dpt:22 ctstate NEW,ESTABLISHED ACCEPT all -- 10.246.0.0/16 10.255.253.4 state RELATED,ESTABLISHED DROP all -- 10.246.0.0/16 10.255.253.4

how do you query icmpttype =8 from the rule? Cant see it anywhere, and there is no documentation. related to it.

also, when i iterate the rules in a chain 'all' returns are 'ip'. and 'icmp' returns as 'ip'.

Whilst i understand the underlying network layer 3. Its not consistent with the iptables command output. any feedback appreciated.

for chain in table.chains: for rule in chain.rules: if hasattr(rule, "protocol"): logging.info("???: " + rule.get_protocol())

???: ip ???: tcp ???: ip ???: ip

thank you

jllorente commented 3 years ago

Try using the "dump_table" function to see what the internals of the iptc rules are: https://github.com/ldx/python-iptables/blob/master/README.md#high-level-abstractions

Paste here the output :)