I've compiled my kernel (2.6.12.3) and iptables (1.3.3) and now -m layer7 option from iptables works (i don't get any error when run the iptables command with -m layer7).
The problem is that no packet is matched. For example iptables -A INPUT -p tcp -m layer7 --l7proto http -j ACCEPT doesn't match http packets. The same for dns and ssh.
So, what am I doing wrong? Is this extension for iptables really working??
I’ve tried on 2 systems (fc3 and slack 10.1)
Here is my iptables test script:
#!/bin/bash
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp --sport 22 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp -m layer7 --l7dir /home/dda/l7dir --l7proto http -j ACCEPT
iptables -A OUTPUT -o eth0 -p tcp -m layer7 --l7dir /home/dda/l7dir --l7proto http -j ACCEPT
iptables -A INPUT -i eth0 -p udp -m layer7 --l7dir /home/dda/l7dir --l7proto dns -j ACCEPT
iptables -A OUTPUT -o eth0 -p udp -m layer7 --l7dir /home/dda/l7dir --l7proto dns -j ACCEPT
iptables -P INPUT DROP
iptables -P OUTPUT DROP
and now: iptables -vnL after generating some http and dns traffic
Chain INPUT (policy DROP 56 packets, 8892 bytes)
pkts bytes target prot opt in out source destination
3340 134K ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
129 9208 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto http
0 0 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto dns
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
3340 134K ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
90 12254 ACCEPT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 tcp spt:22
0 0 ACCEPT tcp -- * eth0 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto http
0 0 ACCEPT udp -- * eth0 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto dns
|