Home > Technology > IPtables Revisited

IPtables Revisited


Some basics of iptables  here

Command to view the contents of different chains

>iptables -L

Command to fush the rules from the chains

>iptables – F

Note:

1.root login is necessary for all the commands related to iptables.

2.Use “ man “ options to get details of the commands i.e “man iptables(in small letters)”

Some rules I practised:

1.      Don’t accept any packets other than ip =”xyz”.

Iptables -A INPUT  ! -s 172.16.17.43 -j DROP

2.      Accept packets only from ip =” xyz”

iptables -A INPUT ! -s 172.16.17.43 -j DROP

iptables -A INPUT -s “xyz” -j ACCEPT

3.      Don’t accept any packets other than mac address =”xyz”.

iptables -A INPUT -m mac ! –mac-source 12:43:32:23:43:23 -j DROP

4.      Accept packets only from mac address =” xyz”

iptables -A INPUT -m mac ! –mac-source 12:43:32:23:43:23 -j DROP

iptables -A INPUT -m mac –mac-source 12:43:32:23:43:23 -j ACCEPT

5.      Don’t accept any packets from  ip =”xyz” and mac address =” “.

iptables -A INPUT ! -s 172.16.23.1 -m mac ! –mac-source 12:32:43:56:21:23 -j DROP

6.      Accept packets only from  ip =”xyz” and mac address =” “

iptables -A INPUT ! -s 172.16.23.1 -m mac ! –mac-source 12:32:43:56:21:23 -j DROP

iptables -A INPUT -s 172.16.23.1 -m mac –mac-source 12:32:43:56:21:23 -j ACCEPT

7.      Accept only tcp connection

iptables -A INPUT ! -p tcp -j DROP

iptables -A INPUT -p tcp -j ACCEPT

8.      Don’t accept packets of udp

iptables -A INPUT  -p udp -j DROP

9.      Don’t Accept packets who’s tcp status is SYN

iptables -A INPUT -p tcp –syn -j DROP

10.      Limit number of tcp connection on the system

iptables -A INPUT -p tcp –syn –dport 23 -m connlimit –connlimit-above 2 -j DROP

11.      Create your own chain .

iptables -N MYCHAIN

12.      Delete our own chain

iptables -X MYCHAIN

13.      Add the some rules in your chain and try out

iptables -A MYCHAIN -s 124.12.67.4 -j DROP

14.      Delete specific rule in your chain.

iptables -D MYCHAIN -s 124.12.67.4 -j DROP

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: