I am new to iptables and trying to set my linux server as a gateway for my other computers.So naturally I am playing with iptables and needed some help
My server has 2 NIC cards, eth0(WAN) and eth1(LAN)
my goals are:
- For me to have ssh access to the linux server
- Forward all http(80) and https(443) traffic coming into eth1(LAN) to eth0 and do ip masquerading
- All other traffic coming into eth1(mainly DHCP requests from LAN clients) should not be forwarded to eth0
- Not allow the LAN clients to run any service ie. only have access to the web(tcp:80/443)
The rules I have so far are:
#To clear all IPTables Rules
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
#allow me to ssh into the server + access the web server on it
#ssh
iptables --table FILTER -A INPUT -p tcp --dport 22 -j ACCEPT
#webserver
iptables --table FILTER -A INPUT -p tcp --dport 80 -j ACCEPT
#drop everything else
iptables --table FILTER -A INPUT -j DROP
#enable IP Masquerading on eth0
iptables --table NAT -A POSTROUTING --out-interface eth0 -j MASQUERADE
#accept incoming traffic from eth1
#http
iptables --table FILTER -A INPUT -p tcp -dport 80 --in-interface eth1 -j ACCEPT
#https
iptables --table FILTER -A INPUT -p tcp -dport 443 --in-interface eth1 -j ACCEPT
#drop everything else
iptables --table FILTER -A INPUT --in-interface eth1 -j DROP
So at this point I have the http/https traffic coming in from eth1(which was allowed to come in by iptables) and my eth0 line ready for masquerading.
My question is How do i forward this traffic from eth1 to eth0 ?
Any help would be much appreciated,
ankit