Email this to a friend
posted on September 13th 2019, at 10:55
by lunarg
To quickly block traffic from/to a specific IPv4 address using iptables, you can use the commands below.

Do not use these commands when you are already running an iptables-based firewall as this may result in unexpected results.

Block incoming traffic from a specific IP:

iptables -A INPUT -s -j DROP

Block outgoing traffic (i.e. traffic initiated from the host itself) to a specific IP:

iptables -A OUTPUT -d -j DROP

To block outgoing traffic to a specific port and protocol, you can also do something like this (the example below blocks DNS and HTTP):

/sbin/iptables -A OUTPUT -p tcp --dport 80 -d -j DROP/sbin/iptables -A OUTPUT -p udp --dport 53 -d  ...

Send a link to this post to yourself or a friend.

Send to e-mail:
Your name:
Your e-mail:
Type the letters and numbers as shown.
Not readable? Get another.
Information entered is solely used for sending a one-time e-mail, and is not retained and/or passed on to a third party.
« February 2021»
« I needed a password with eight characters so I picked Snow White and the Seven Dwarves. »