Quickly allowing/denying IP’s using iptables


How do you block an IP using iptables?

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

How do you block an IP from a specific port?

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

How do you allow access to an IP?

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

How do you 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
(xx.xx.xx.xx is the remote IP address and PORT is the port number you wish to allow/deny access to.)

How do you block a scanner on a server for example "blablabla.at.ISC.SANS" using iptables?

iptables -I INPUT -p tcp --dport 80 -m string --algo bm \
--string 'GET /blablabla.at.ISC.SANS.' -j DROP 

Was this answer helpful?

 Print this Article

Also Read

Install ClamAV antivirus

Install ClamAV antivirus softwareInstall EPEL repo:For CentOS 6 32-bit execute command:rpm -Uvh...

Create an SPF record for domain

The Sender Policy Framework (SPF) is a method of fighting spam. As more time passes, this...

Secure mail server checklist

Setup of email server in Linux is simple, but your job does not end there. Customer had...

Secure VPS Tips

Here is a simple, straightforward guide to improve VPS security. Change the SSH port One of the...

Installing Rkhunter (Rootkit Hunter)

First download the latest stable version of Rkhunter tool:wget...