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

eth0: (LAN1)
eth1: (Internet)
eth2: (LAN2)


$ route -n

Kernel IP routing table
Destination     Gateway         Genmask         Indic Metric   Ref  Use Iface         UG    0        0    0   eth1   UG    0        0    0   eth2   U     1        0    0   eth2     U     1000     0    0   eth2   U     1        0    0   eth1     UG    0        0    0   eth0   U     1        0    0   eth0

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


From this PC (PC1), I am connected to the Internet and I can ping all IPs in this range and this IP i cannot ping the other IPs in this range (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 range

  • 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 '13 at 17:13
  • This covers the same ground as askubuntu.com/questions/250370/… , but that Q/A is not very enlightening. – belacqua Jun 7 '13 at 17:23

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

Alternatively, you can masquerade the 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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.