I m blocking an ip from my centos server using iptables:
iptables -A INPUT -s $ip -j DROP service iptables save
however my ip is still able to access the ip and even view websites hosted on this ip. what's wrong?
You'll have to block the outgoing traffic to this ip address not the other-way around.
Use the OUTPUT
keyword and the -d
flag like this:
iptables -A OUTPUT -d $ip -j DROP
-d
flag to specify the IP as destination, not source. And of course you may run afoul of the fact that order is important in iptables
rules, and slapping one on the end of a chain doesn't guarantee it'll ever do anything at all.
Sep 10, 2014 at 15:39