4

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 (http://www.linux.org/PRIVOXY-FORCE/docs/ldp/howto/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html), 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 192.168.1.2:8080
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.2:8080

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?

1
  • 1
    This question doesn't belong on Stack Overflow
    – Joel Coel
    Commented Dec 12, 2010 at 3:49

2 Answers 2

1

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

1

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

Works great even for PPP and DHCP interfaces.

You must log in to answer this question.