Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, I have 3 NICs on a server, 1 connects to a adsl modem(eth0), another connects to a optical fiber(ppp0) and the other to a LAN(eth2).

I've set up all the interfaces, routes and rules as described here (, and it works perfectly. I can connect externally to both hosts without any problems, but I'm facing another problem now...

I can only do NAT on the host that I've set up as the default route on the main table. For example, if I use these rules:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to-destination
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 80 -j DNAT --to-destination

It works depending on the default route. If the default route is via eth0, incoming connections from ppp0 do not get redirected to the LAN machine. Also, if the default route is via ppp0, connections from eth0 will not be redirected. I have a table for each provider with the gateway configured as default route, but it doesn't seem to work for NAT.

Does anyone have an idea to fix this issue?

share|improve this question

migrated from Dec 12 '10 at 4:02

This question came from our site for professional and enthusiast programmers.

This question doesn't belong on Stack Overflow – Joel Coel Dec 12 '10 at 3:49

The "default route" is meaningless if you have setup your routes with "ip route" correctly. The difficulty comes from the fact that both eth0 and ppp0 are likely to be setup by DHCP, which will overwrite whatever you had setup.

You should give the output of "ip route show" for all the tables you have setup, as well as "ip rule show" and anything else you've done during setup.

BTW, the link you posted did not work for me, this one does

share|improve this answer

I have done this using CONNMARK, firewall marking, and multiple routing tables.

Works great even for PPP and DHCP interfaces.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.