Using iptables to block ALL outgoing traffic from one NIC?

35,326

Solution 1

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.

Solution 2

To drop all the outgoing traffic on eth1

iptables -I OUTPUT -o eth1 -j DROP

will insert a rule at the begining of the OUTPUT chain to drop all outgoing traffic.

Share:
35,326

Related videos on Youtube

edanfalls
Author by

edanfalls

Apparently, this mystery prefers them to air an about user of keep.

Updated on September 17, 2022

Comments

  • edanfalls
    edanfalls over 1 year

    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.

  • edanfalls
    edanfalls about 13 years
    Thanks. Both were what I was looking for (no current rules so append or insert is fine) - but I've given it to kenny.r for being first.
  • Socrates
    Socrates over 6 years
    Info for the difference between OUTPUT and FORWARD here: unix.stackexchange.com/questions/96548/…