need some help on configuring iptables rule for forwarding and masquerading
Given I have these configuration:
switch1 ---- (eth1) ----- router ---- (eth2) ----- switch2
where multiple PCs are connected though switch1 and switch2 as well
i'm running this network on a Ubuntu Server where I assume eth1 and eth2 have the same IP address since the default gateway for all the connected PCs is the IP address of this router.
so what i did are :
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
iptables -A FORWARD -i eth2 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iface lo inet loopback
iface eth0 inet static
iface eth1 inet static
iface eth2 inet static
So the problem is that all the PCs connected to the router through eth2 can't connect to the internet (tuntap) but all the PCs connected trough the eth1 can do.
Thus, is there anything I miss on configuring the iptables? Or did I misunderstood?
Help and suggestions are really appreciated. I just started on learning comp networking a month ago, so basically need a guidance here. Thanks a lot :)