Tuesday, September 29, 2009

How can I block IP addresses?

SkyHi @ Tuesday, September 29, 2009
[home]$ /bin/netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort |uniq -c | sort -n |more
1 142.32.208.232
1 142.58.185.157
1 154.5.60.241
1 164.77.228.99
1 192.28.0.22
1 192.168.100.235
1 208.80.193.29
1 213.250.36.94
1 66.249.67.34
1 72.30.142.170
1 98.188.147.225
1 Address
1 servers)
2 41.4.138.112
2 67.195.115.54
3 192.168.100.236
3 209.216.175.95
3 213.39.187.103
4 192.168.100.18
6 192.168.100.16
6 74.13.129.145
6 79.65.242.231
8 199.60.221.132
13 65.2.116.47
31 192.168.100.46


Block un-wanted IPs using IPTables

/sbin/iptables -I INPUT -s 12.34.56.78 -j DROP
/sbin/service iptables save
/sbin/service iptables restart