Wednesday, January 27, 2010

Howto: deny/allow IP using iptables

How to block an IP using iptables?

iptables -A INPUT -s xx.xx.xx.xx -j DROP

How to block an IP for a specific port:

iptables -A INPUT -p tcp -s xx.xx.xx.xx –dport PORT -j DROP

How to allow access to an IP?

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

How to allow access to an IP to a specific port using iptables?

iptables -A INPUT -p tcp -s xx.xx.xx.xx –dport PORT -j ACCEPT

where, xx.xx.xx.xx is the remote IP address and PORT is the port number you wish to allow/deny access to.

How to block a scanner on your server for example “w00tw00t.at.ISC.SANS” using iptables?

iptables -I INPUT -p tcp –dport 80 -m string –string ‘GET /w00tw00t.at.ISC.SANS.’ -j DROP

No comments:

Post a Comment