Thursday, November 24, 2011

listing iptables

If we want to listing all rules of our iptableswith othe information, here is the command:

iptables -L INPUT -n --line-numbers
iptables -L OUTPUT -n --line-numbers
iptables -L OUTPUT -n --line-numbers | less
iptables -L spamips -n -v --line-numbers
iptables -L spamips -n -v --line-numbers | grep 202.54.1.2

here is the example:
internal:/home/fatur # iptables -L OUTPUT -n --line-numbers
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
1 PORT12_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:143
2 PORT11_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:53
3 PORT10_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:3128
4 PORT09_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:4559
5 PORT08_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:3306
6 PORT07_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:139
7 PORT06_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:110
8 PORT05_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:23
9 PORT04_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:221
10 PORT03_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:81
11 PORT02_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:21
12 PORT01_OUT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:25
13 DROP tcp -- 0.0.0.0/0 0.0.0.0/0 STRING match "mediafire.com" ALGO name kmp TO 65535
14 DROP tcp -- 0.0.0.0/0 0.0.0.0/0 STRING match "microsoft.com" ALGO name kmp TO 65535

Now we want to delete the rules:

internal:/home/fatur # iptables -D OUTPUT 16

No comments: