HOW TO BLOCK AN IP ADDRESS ON A LINUX SERVER

0
(0)

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. For example, if you wish to block an ip address 45.13.39.115 for whatever reason then type the command as follows:

# iptables -A INPUT -s 45.13.39.115 -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 45.13.39.115 to TCP-port 22 (ssh) then type command:

# iptables -A INPUT -s 45.13.39.115 -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 45.13.39.115 -j DROP
# service iptables save

HOW TO UNBLOCK AN IP ADDRESS ON A LINUX SERVER

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

# iptables -D INPUT -s 45.13.39.115 -j DROP
# service iptables save

Similar Posts:

1,101

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Scroll to Top