Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a question.

I have a ubuntu server(GW0). It has 2 interfaces.

eth0: - connected to router

eth1: - connected to switch

eth0:, gw:

eth1:, gw: ( server placed in my network it has internet access)

I want to use this server(GW0) as my gateway for my network to access 10.20.x.x subnets via router and internet access from

What i did.

  1. echo 1 > /proc/sys/net/ipv4/ip_forward
  2. route add default gw

if i do like this internet works fine from my network, but can't access 10.20.x.x.

update 1: if i use default gw

  iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  iptables -A FORWARD -i eth0 -j ACCEPT

i can access 10.20.x.x, but not internet.

Than i try to use iproute.

echo 1 corp >> /etc/iproute2/rt_tables
ip route add default via dev eth0 table corp
ip rule add from table corp

How to make to this work to reach 10.20.x.x and internet. Thanks beforehand.

share|improve this question

1 Answer 1

you need a specific route to cover the /16

policy based routing is unnecessary.

ip route add default via

ip route add via

share|improve this answer
i added ip route add default via and ip route add via But still my network can't reach 10.20.x.x. Can you explain step by step pls. Thanks – sarik_in Mar 3 '13 at 7:41
The machines you want to reach need to know how to get traffic back to you. – David Schwartz Mar 3 '13 at 8:26

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.