Search:  
Gentoo Wiki

TIP_Block_an_IP

This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

A simple line to block an IP with iptables

iptables -I INPUT -s  146.83.34.32  -j DROP

To view blocked IPs and other iptables commands:

iptables -L -n

Batch block IP's

It's plain and simple, works great on my firewall:

script:

 #!/bin/sh
 for i in $(< bad_hosts.lst) ; do
   iptables -I INPUT -i eth1 -s "$i" -j DROP
 done

bad_hosts.lst:

 192.168.2.1
 192.168.2.2
 ...
Retrieved from "http://www.gentoo-wiki.info/TIP_Block_an_IP"

Last modified: Sun, 18 Feb 2007 05:06:00 +0000 Hits: 7,353