Block an IP Address on a Linux server running iptables.

To block an IP on your Linux server you need to use iptables tools  and netfilter firewall. 

First you need to log into shell as root user. 


To block an IP address you need to type the iptables command as follows: 


# iptables -A INPUT -s IP_address -j DROP 


Replace IP_address with your actual IP address which you want to block. 

For example, if you wish to block an ip address 192.168.10.25 for whatever reason then type the command as follows: 

# iptables -A INPUT -s 192.168.10.25 -j DROP 


If you have IP tables firewall script, add the above rule to your script.If you just want to block access to one port from an ip 192.168.10.25 to port 22 then type command: 

# iptables -A INPUT -s 192.168.10.25 -p tcp --destination-port 22 -j DROP 


For CentOS / RHEL / Fedora operating systems, in-order to block An IP And Save It To Config File Type the following commands: 


# iptables -A INPUT -s 192.168.10.25 -j DROP # service iptables save




No comments:

Post a Comment

Thank You.

https://linwintech.blogspot.com/