I am a bit stuck with iptables to do deal with two Ethernet ports.
eth0 port for LAN use (192.168.1.50 Private IP).
eth1 port is connected to the internet via cable modem (80.0.xxx.xxx public IP).
eth0 Link encap:Ethernet HWaddr 00:19:99:C1:86:BB
inet addr:192.168.1.50 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:137532 errors:0 dropped:0 overruns:0 frame:0
TX packets:55658 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:99968969 (95.3 MiB) TX bytes:10403525 (9.9 MiB)
Interrupt:50 Memory:fe700000-fe720000
eth1 Link encap:Ethernet HWaddr 00:19:99:C1:61:3B
inet addr:80.0.xxx.xxx Bcast:255.255.255.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:144558 errors:0 dropped:0 overruns:0 frame:0
TX packets:70347 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:34500131 (32.9 MiB) TX bytes:27893843 (26.6 MiB)
Interrupt:177 Memory:fe600000-fe620000
I wanted to block all the incoming route to eth1
but only allow port 21. Just so that external IP can't access to our web server, ftp server, etc. Only allow port 21 for SSH access. Ping should work too.
On the local network (eth0), anyone should be able to access anything but just block local ip's 192.168.1.20 and 192.168.1.30 from accessing to 192.168.1.50 server.
How can it be done using iptables?