Monday, April 15, 2013

Iptables

Iptables is a firewall built into linux kernel.
Iptables is used for IPv4 and ip6tables is used for IPv6.
Iptables contain four tabels : raw, filter, nat and mangle.
There are three built in chains :
-Chain input
-Chain output
-Chain forward
We can set the target of packet using the options -j (jump).
The most used target are : ACCEPT, REJECT, DROP, LOG.
sudo iptables -L -> check the current rules of iptables.
For more informations about current rules type : sudo iptables -L -v
-v -> verbose mode
With syntax " iptables -P chain target [options] " we can chenge the rules.
For example : sudo iptables -P INPUT DROP
We drop all input packet.
After drop all input we can modify options ensuring traffic request by us:
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A -> -A Chain : Append to chain
-m state-> extended match (state in this case)
-j -> jump options
We can also specify a interface for example lopback
sudo iptables -A INPUT -i lo -j ACCEPT
-i -> specify interface
We can also ensure a traffic by specific port:
sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT

I reccomend you to don't modify OUTPUT chain because linux doesn't work like windows that send in output our datas.

Now if you type : sudo iptables -L -v you can see the modify ;)

If you have a problem or you need some explanations just write under this post!

No comments:

Post a Comment