Linux – How to block certain IP address to access certain domain/IP via iptables in Linux

centosiptableslinux

How to block certain IP address to access certain domain/IP in Linux ?

I have CentOS installed on my server for virtual server purposes. I have a few virtual servers clients each one with his own IP. I need to block their IP to access certain domain.

I know this iptables rules totally blocks access to certain IP but I only need to limit the access only to a few clients, so this one block total access :

iptables -A OUTPUT -d 123.123.123.123 -j DROP

I need one rule that will mention what IP would be blocked from access 123.123.123.123

Best Answer

Use the -s | --source address parameter to filter on the source address.

iptables -I OUTPUT -s a.b.c.d  -d w.x.y.z -j DROP
Related Topic