Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.
sa3i9a

How do I block the IP address of your server on Linux?

This lesson highlights how to block IP addresses from your server on a Linux system.  Follow us ...

Block the IP address

For a particular IP address block, use the following command, and then you will need to save the changes to iptables, and we will also need to perform some of the save procedures in the config file, otherwise you will lose these actions if your server is restarted.  Replace xx.xx.xx.xx with the IP address that you want to block:

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

service iptables save

Block an IP address from a specific port (port)

Use the following command, replacing yy with the port number, and replacing xx.xx.xx.xx with the required IP address:

iptables - A INPUT - s xx . xx . xx . xx - p tcp - destination - port yy - j DROP

Unblock the IP address

You may block an incorrect address that you do not want to block, or for any other reason ... In this case you will need to use the following two commands, replacing xx.xx.xx.xx with the required IP address:

iptables - D INPUT - s xx . xxx . xx . xx - j DROP service iptables save

Block a domain for an IP address

This is useful if you want to block certain sites (ie a country), specific Internet providers, or designated users on a range of domains, you can block some 8, 16-24 domains, see the following commands:

  • An 8-band ban command, for example from address xyz0 to xyz255
iptables - A INPUT - s xx . yy . zz . 0 / 8 - J the DROP 
  • Block 16 command, for example from address xy0.0 to xy255.255
Locate website visitors for free using ipfinder - a free, real-time IP address to location JSON API and database service supporting IPv4 and IPv6 lookup. ip finder
iptables - A INPUT - s xx . yy . 0.0 / 16 - j DROP 
  • Block command 32 range, for example from address x.0.0.0 to x.255.255.255
iptables - A INPUT - s xx . 0.0 . 0 / 24 - J the DROP 
Locate website visitors for free using ipfinder - a free, real-time IP address to location JSON API and database service supporting IPv4 and IPv6 lookup. ip finderLocate website visitors for free using ipfinder - a free, real-time IP address to location JSON API and database service supporting IPv4 and IPv6 lookup. ip finder
Tags: ip

Don't be the product, buy the product!

Schweinderl