iptables rule to submit packets matching a specific negative rule
- by Aditya Sehgal
I am using netfilter_queue to pick up certain packets from the kernel and do some processing on them. To, the netfilter queue, I need all packets from a particular source except UDP packets with src port 2152 & dst port 2152.
I try to add the iptable rule as
iptables -A OUTPUT ! s 192.168.0.3 ! -p udp ! --sport 2905 ! --dport 2905 -j NFQUEUE --queue-num 0
iptables throw up an error of Invalid Argument. Querying dmesg, I see the following error print
ip_tables: udp match: only valid for protocol 17
I have tried the following variation with the same error thrown.
iptables -A OUTPUT ! s 192.168.0.3 ! -p udp --sport 2905 --dport 2905 -j NFQUEUE --queue-num 0
Can you please advise on the correct usage of the iptables command for my case.