Block an IP Address on a Linux server

An IP addresses are often blocked to keep the unwanted visitors away. Every entity, i.e. every internet connection has an IP address. Blocking an IP address means, the particular internet user (whose IP address has been blocked) will not be able to access the blocked information any more.

Blocking an IP address on a Linux server is different from Windows.

If you want to block an IP on a Linux server you will require netfilter firewall and iptables tools. Iptable tools are administrative tools designed for IPv4 packet filtering.

After you have logged as a root user, here is the command to enter:

iptables -A INPUT -s IP-ADDRESS -j DROP

When entering this command, insert the IP address where it says IP-ADDRESS. If the person you wish to block has an IP address which is 75.33.41.107, the command should look like this:

iptables -A INPUT -s 75.33.41.107 -j DROP

Make sure enter the command in the exact same way, with all the spaces and characters included. If there is IP tables firewall script available, insert the rule you just made into the script.

Furthermore, if you wish to block an IP from one particular port, e.g. you want the IP 75.33.41.107 blocked from port 32, type in this command:

iptables -A INPUT -s 75.33.41.107 -p tcp --destination-port 32 -j DROP

This command will create a rule that will automatically lose all packets from IP 75.33.41.107 to the port mail server port 32. Again, make sure you have entered the command precisely.

Originally posted 2011-03-29 13:36:32.

Posted in IP Address
Tags: , , , , ,

Leave a Reply

4 Comments on "Block an IP Address on a Linux server"

Notify of
avatar
Sort by:   newest | oldest | most voted
hotrod
Guest

How do you get a long distance IP address? the phone company is telling me that there is no such thing. I just moved and now I’m having trouble.
PLEASE HELP!!!!!!!!!!!!!!

ip address
Guest

I like concept of your post. Very creative post. Best of luck and waiting for some new ideas. I am looking for such useful information and I found here a lot of it. Nice article and exactly what I need. Most of all I like the style. Great job,
Ip address

google
Guest

good post

wpDiscuz