Linux

Categorized | Networking, Security

IPTABLES - blocking IPs simplified

You can block an IP from IPTABLES by using

iptables -I INPUT -s 192.168.0.88 -j DROP

You can simplify things a little bit by using a shell script and a predefined text file containing the IPs we want to be blocked. Either create a new file or add the following at the end of the script which activates the firewall:

#!/bin/sh

for i in $(< bad_hosts.lst) ; do

iptables -I INPUT -i eth1 -s “$i” -j DROP

done

Now create a new file in the same directory and name it bad_hosts.lst and add a new IP to be blocked on every single line, like in the example below:

192.168.2.99

192.168.2.67

86.138.2.7

Author Profile

T4L ;

Other posts by T4L

Author's web site



Are you satisfied with this blog?
Why not subscribe our RSS Feed? you will always get the latest post.


Hi, Be the first leave some reply

Leave A Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>