5

I want to configure Ubuntu 12.04 as a router. This Ubuntu PC has 3 network cards

eth0:192.168.1.203 (LAN1)
eth1:172.16.30.21 (Internet)
eth2:10.216.1.107 (LAN2)

and

$ route -n

Kernel IP routing table
Destination     Gateway         Genmask         Indic Metric   Ref  Use Iface
0.0.0.0         172.16.30.1     0.0.0.0         UG    0        0    0   eth1
10.216.1.0      10.216.1.1      255.255.255.0   UG    0        0    0   eth2
10.216.1.0      0.0.0.0         255.255.255.0   U     1        0    0   eth2
169.254.0.0     0.0.0.0         255.255.0.0     U     1000     0    0   eth2
172.16.30.0     0.0.0.0         255.255.255.0   U     1        0    0   eth1
192.168.0.0     192.168.1.3     255.255.0.0     UG    0        0    0   eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     1        0    0   eth0

If I configure another Windows PC (PC1) like this :

ip:192.168.1.29
mask:255.255.255.0
gw:192.168.1.203

From this PC (PC1), I am connected to the Internet and I can ping all IPs in this range 192.168.0.0/16 and this IP 10.216.1.107.but i cannot ping the other IPs in this range 10.216.1.0/24 (i can ping this range from ubuntu pc).

My problem is how to modify my route table to assure a connection between PC1 and all PCs in 10.216.1.0/24 range

2
  • 1
    Depending on how robust this needs to be, you might want to look at the quagga package, or at the vyatta (Debian-based but not Ubuntu) system.
    – belacqua
    Jun 7, 2013 at 17:13
  • This covers the same ground as askubuntu.com/questions/250370/… , but that Q/A is not very enlightening.
    – belacqua
    Jun 7, 2013 at 17:23

1 Answer 1

1

The computers in network 10.216.1.0/24 don't know the route to network 192.168.1.0/24, that's why they can't communicate. You have to set a static route in router2 redirecting 192.168.1.0/24 to 10.216.1.107.

Alternatively, you can masquerade the 192.168.1.0/24 network behind eth2 IP address using iptables:

iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE

The packages leaving eth2 will have their source IP changed to 10.216.1.107.

3
  • this command iptables -A OUTPUT -o eth2 -j MASQUERADE return this error iptables: Invalid argument. Run 'dmesg' for more information.
    – Yezzy Sarl
    Jun 9, 2013 at 12:06
  • 1
    @YezzySarl sorry, answer updated. Jun 9, 2013 at 15:17
  • iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE its the best. thanks
    – Yezzy Sarl
    Jun 12, 2013 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .