need some help on configuring iptables rule for forwarding and masquerading
Given I have these configuration:
switch1 ---- (eth1) ----- router ---- (eth2) ----- switch2
|
|
(eth0)
|
|
internet
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
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.151.74.30
netmask 255.255.255.252
gateway 10.151.74.29
auto eth1
iface eth1 inet static
address 172.16.0.1
netmask 255.255.255.0
auto eth2
iface eth2 inet static
address 172.16.0.1
netmask 255.255.255.0
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 :)
ip a ls
andip r ls
?