When you says its not working, is something about you did't able to block it?
Run this: iptables -L -v --line-numbers
And paste here.
You will get something like this:
Code:
[root@testkvm ~]# iptables -L -v --line-numbers
Chain INPUT (policy ACCEPT 46830 packets, 2500K bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT udp -- virbr0 any anywhere anywhere udp dpt:domain
2 0 0 ACCEPT tcp -- virbr0 any anywhere anywhere tcp dpt:domain
3 0 0 ACCEPT udp -- virbr0 any anywhere anywhere udp dpt:bootps
4 0 0 ACCEPT tcp -- virbr0 any anywhere anywhere tcp dpt:bootps
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 SOLUSVM_TRAFFIC_IN all -- any any anywhere anywhere
2 0 0 SOLUSVM_TRAFFIC_OUT all -- any any anywhere anywhere
3 0 0 ACCEPT all -- any virbr0 anywhere 192.168.122.0/24 state RELATED,ESTABLISHED
4 0 0 ACCEPT all -- virbr0 any 192.168.122.0/24 anywhere
5 0 0 ACCEPT all -- virbr0 virbr0 anywhere anywhere
6 0 0 REJECT all -- any virbr0 anywhere anywhere reject-with icmp-port-unreachable
7 0 0 REJECT all -- virbr0 any anywhere anywhere reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT 4129 packets, 136M bytes)
num pkts bytes target prot opt in out source destination
Chain SOLUSVM_TRAFFIC_IN (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 all -- any any anywhere 199.2xx.1xx.55
2 0 0 all -- any any anywhere 199.2xx.1xx.56
Chain SOLUSVM_TRAFFIC_OUT (1 references)
num pkts bytes target prot opt in out source destination
1 0 0 all -- any any 199.2xx.1xx.55 anywhere
2 0 0 all -- any any 199.2xx.1xx.56 anywhere
Lokking at this, you see, the forward has 2 rules at top. TRAFFIC_IN / TRAFFIC_OUT.
That says you will forward the traffic to the new chain rules traffic in and out.
When you use iptables with -A option, you add a rule at finish, and on this case in this exemple, if you do it, these rules will not work, because the rules are after the in and out chain rules.
Give a try to use with option -I instead of -A, with -I you will put the rules at top of the forward chain rule, then this will block first and will not forward to the next rules.
Another think, add bad boots to this rules too:
block bat bots - see
http://puntapirata.com/
Anonymizer
Attributor
Bork-edition
DataCha0s
Deepnet Explorer
desktopsmiley
DigExt
feedfinder
gamingharbor
heritrix
ia_archiver
Indy Library
Jakarta
Java
juicyaccess
larbin
Missigua
MRSPUTNIK
Nutch
panscient
plaNETWORK
Snapbot
Sogou
TinEye
TwengaBot
Twitturly
User-Agent
Viewzi
WebCapture
XX
Yandex
YebolBot
Also add hard spammers bot
baidu
hinet
Baidu
Hinet
I love iptables, if you have some time, give a try to learn how to do some scripts to automatic update your rules. Like this GREAT script from:
http://sysadminnotebook.blogspot.com.br/2013_07_01_archive.html
Code:
#!/bin/bash
BLOCKDB="block.txt"
WORKDIR="/tmp"
pwd=$(pwd)
cd $WORKDIR
#List of ips to block
ipset --create blackips iphash
## Obtain List of badguys from openbl.org
wget -q -c --output-document=$BLOCKDB http://www.openbl.org/lists/base.txt
if [ -f $BLOCKDB ]; then
IPList=$(grep -Ev "^#" $BLOCKDB | sort -u)
for i in $IPList
do
ipset --add blackips $i
done
fi
rm $BLOCKDB
## Obtain List of badguys from ciarmy.com
wget -q -c --output-document=$BLOCKDB http://www.ciarmy.com/list/ci-badguys.txt
if [ -f $BLOCKDB ]; then
IPList=$(grep -Ev "^#" $BLOCKDB | sort -u)
for i in $IPList
do
ipset --add blackips $i
done
fi
rm $BLOCKDB
## Obtain List of badguys from dshield.org
wget -q -c --output-document=$BLOCKDB http://feeds.dshield.org/top10-2.txt
if [ -f $BLOCKDB ]; then
IPList=$(grep -E "^[1-9]" $BLOCKDB | cut -f1 | sort -u)
for i in $IPList
do
ipset --add blackips $i
done
fi
rm $BLOCKDB
#List of networks to block
ipset --create blacknets nethash
## Obtain List of badguys from dshield.org
wget -q -c --output-document=$BLOCKDB http://feeds.dshield.org/block.txt
if [ -f $BLOCKDB ]; then
IPList=$(grep -E "^[1-9]" $BLOCKDB | cut -f1,3 | sed "s/\t/\//g" | sort -u)
for i in $IPList
do
ipset --add blacknets $i
done
fi
rm $BLOCKDB
## Obtain List of badguys from spamhaus.org
wget -q -c --output-document=$BLOCKDB http://www.spamhaus.org/drop/drop.lasso
if [ -f $BLOCKDB ]; then
IPList=$(grep -E "^[1-9]" $BLOCKDB | cut -d" " -f1 | sort -u)
for i in $IPList
do
ipset --add blacknets $i
done
fi
rm $BLOCKDB
#Drop blacklisted ips
iptables -A FORWARD -m set --match-set blackips src -j DROP
iptables -A FORWARD -m set --match-set blacknets src -j DROP
cd $pwd