Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

share|improve this question
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… , but that Q/A is not very enlightening. – belacqua Jun 7 '13 at 17:23

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
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
@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 posting your answer, you agree to the privacy policy and terms of service.

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