Hello Guest, if you read this, it means you are not registered. Click here to register a few simple steps, you will enjoy all the features of our Forum. Please note that nicknames are prohibited lewd or meaningless (no numbers or letters at random) and introduce yourself in the section for you to meet our community.
How to Block/UnBlock an IP address on Centos / Linux Server - Blogs - GOZEN Host Forums
View RSS Feed

GOZEN Host blogs

How to Block/UnBlock an IP address on Centos / Linux Server

Rate this Entry
by , 10-15-2016 at 04:21 PM (4268 Views)
To block an IP on your Linux server you need to use iptables tools. 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 like the following example.

iptables -A INPUT -s 198.168.2.1 -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.2.1 to port 22 then type command:

iptables -A INPUT -s 192.168.2.1 -p tcp --destination-port 22 -j DROP
CentOS / RHEL / Fedora Block An IP And Save It To Config File
Type the following two command:
iptables -A INPUT -s 192.168.2.1 -j DROP
service iptables save
How to UnBlock an IP Address on Centos / Linux Server

Use the following syntax (the -d options deletes the rule from table):

iptables -D INPUT -s 192.168.2.1 -j DROP
service iptables save

Submit "How to Block/UnBlock an IP address on Centos / Linux Server" to Digg Submit "How to Block/UnBlock an IP address on Centos / Linux Server" to del.icio.us Submit "How to Block/UnBlock an IP address on Centos / Linux Server" to StumbleUpon Submit "How to Block/UnBlock an IP address on Centos / Linux Server" to Twitter

Tags: None Add / Edit Tags
Categories
Tips and Tricks for Beginners

Comments