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

Wednesday, November 16, 2011

Wednesday, November 2, 2011

saving you iptables

this tutorial work on OpenSUSE 11.04, if you want to save the configuration of tour iptables, do this command on root level:

iptables-save > /etc/sysconfig/iptables-net

if you want this config always load after restart/ reboot your machine,
Edit with pico, mcedit or vi:/etc/init.d/network

# mcedit /etc/init.d/network

insert this command

iptables-restore < /etc/sysconfig/iptables-net

Done.....