Linux – Using iptables to block ALL outgoing traffic from one NIC

iptableslinuxlinux-networkingrouter

I must pretty bad at Googling as this seems like a very basic question but I can't seem to find the answer anywhere… and man iptables is a very long read!

I have two NICs – eth0 and eth1 – on a linux box and I want to block ALL outbound traffic (TCP and UDP across all ports) from one of the NICs, so that no traffic makes its way back up to the router.

What is the command for this? I have only seen examples with specific ports.

Thanks in advance.

Best Answer

With iptables -A OUTPUT -o eth1 -j DROP you can drop all outgoing traffic on interface eth1. You'll probably also want to drop all forwarded traffic using iptables -A FORWARD -o eth1 -j DROP.