iptables handy guide

iptables used to setup, maintain and inspect the tables of IP packet filter rules through Linux Kernel. You can modify or manage the rules through the command from console or SSH.

To list the IPs that is being blocked, you may run the command as below.

iptables -L -n

You will get the list of the IP that is being listed from the Iptables Kernel rules as command above.

To block an IP using iptables,

iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP

where xxx.xxx.xxx.xxx is the actual IP

To block an IP using specify port,

iptables -D INPUT -p tcp -s xxx.xxx.xxx.xxx -dport PORT -j DROP

where PORT is the port number that wish to block

To allow an IP to access.

iptables -A INPUT -s xxx.xxx.xxx.xxx.xxx -j ACCEPT

To allow an IP using specify Port,

iptables -A INPUT -s xxx.xxx.xxx.xxx -dport PORT -j ACCEPT

To block IP in range,

iptables -D INPUT -s xxx.xxx.xxx.xxx/yy -j DROP

where yy is the network range.

Published by

Mick Genie

Mick Genie is the founder of MickGenie.com and working at ExaBytes Network Sdn Bhd and WPWebHost web host company. He is expertise in Windows and Linux environment especially web hosting related information, tips and trick as well as the IT Information.

One thought on “iptables handy guide”

Comments are closed.