- I am trying to do a proper setup of IPTABLES for a multihomed computer.
The computer that is doing this will also be doing web, mail, print servering,
and other misc roles. All roles will be minimal load levels.
- Interface Address
A) eth0 192.168.0.1
B) eth1 192.168.1.1
C) eth2 dynamic(ISP assigned)
A/B should be blocked. A & B are both segments that need to be allowed
to the internet and at this point to one another. Right now I need
full access between the 2 segments but in the future I will need to
restrict that to allow only certain things to be allowable. - Interface Address
- Looking at the docs on setting up a home server this is what I think will
let me do my goal. Can someone that is more familiar with IPTABLES tell
me if I did this correctly or if this has major holes in it??Code: Select all
iptables -F iptables -t nat -F #lock down services iptables -I INPUT 1 -i eth0 -j ACCEPT iptables -I INPUT 1 -i eth1 -j ACCEPT iptables -I INPUT 1 -i lo -j ACCEPT iptables -A INPUT -p UDP --dport bootps -i ! eth0 -j REJECT iptables -A INPUT -p UDP --dport bootps -i ! eth1 -j REJECT iptables -A INPUT -p UDP --dport domain -i ! eth0 -j REJECT iptables -A INPUT -p UDP --dport domain -i ! eth1 -j REJECT #Allow access to the ssh server from the WAN iptables -A INPUT -p TCP --dport ssh -i eth2 -j ACCEPT #Drop TCP/UDP packets to priveleged ports iptables -A INPUT -p TCP -i ! eth0 -d 0/0 --dport 0:1023 -j DROP iptables -A INPUT -p TCP -i ! eth1 -d 0/0 --dport 0:1023 -j DROP iptables -A INPUT -p UDP -i ! eth0 -d 0/0 --dport 0:1023 -j DROP iptables -A INPUT -p UDP -i ! eth1 -d 0/0 --dport 0:1023 -j DROP #add the NAT rules iptables -I FORWARD -i eth0 -d 192.168.0.0/255.255.255.0 -j DROP iptables -I FORWARD -i eth1 -d 192.168.1.0/255.255.255.0 -j DROP iptables -A FORWARD -i eth0 -s 192.168.0.0/255.255.255.0 -j ACCEPT iptables -A FORWARD -i eth1 -s 192.168.1.0/255.255.255.0 -j ACCEPT iptables -A FORWARD -i eth2 -d 192.168.0.0/255.255.255.0 -j ACCEPT iptables -A FORWARD -i eth2 -d 192.168.1.0/255.255.255.0 -j ACCEPT iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE #tell the kernel ip forwarding is OK echo 1 > /proc/sys/net/ipv4/ip_forward for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done #so on reboot routing in place /etc/init.d/iptables save rc-update add iptables default

