python-iptables icon indicating copy to clipboard operation
python-iptables copied to clipboard

query icmp ype from rule

Open dmzoneill opened this issue 5 years ago • 1 comments

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

dmzoneill avatar Sep 03 '20 20:09 dmzoneill

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 :)

jllorente avatar Sep 24 '20 18:09 jllorente