iptables On for eth0 and off for other interfaces

Hi all,

I am running a CentOS 6.4 box as an IDS and I need to configure one interface as the management interface which will require a firewall. However other ports (in promisc mode without IP) will have to be configured such that IPtables allows all traffic.

I need to achieve this by editing the /etc/sysconfig/iptables file.
So I want to keep all the existing inbound rules in there for some interfaces, but for other interfaces I need to allow all traffic in/out for IDS capture.

What is the best syntax to achieve this by fixed entries in /etc/sysconfig/iptables

Thanks,
Ll

Depends what your rules are already.

Here is my current iptables file:

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
-A INPUT -p tcp --dport 11000:11010 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

So the above applies to all interfaces, but I want to specify interfaces in this file which allow all traffic both in and out. Lets say I want to exclude eth1 and eth3 from iptables rules.

Hmm. You might be able to whitelist traffic to/from those interfaces by putting blanket rules to catch them, before any others:

-A INPUT -i eth1 -j ACCEPT
-A OUTPUT -i eth1 -j ACCEPT

-A INPUT -i eth3 -j ACCEPT
-A OUTPUT -i eth3 -j ACCEPT

That way, iptables will check these rules first, and should go straight to ACCEPT for those interfaces.

I'm not sure whether you'd need a rule for the FORWARD chain as well.

1 Like

That looks like just what I was looking for. I'll do some testing with it.