SNAT/MASQUERADE with two uplink connections

From: Marek Zachara (marek-no_at_sp-am-telperion.pl)
Date: 12/27/04


Date: Mon, 27 Dec 2004 21:01:40 +0100

Hi all,

I've been messing around with different configs to get it working, but to no
avail.
I have a linux box (lets call it RTR) with 3 interfaces:
eth0 (192.168.x.x) is the internal LAN
eth1 and eth2 are connected each to a dsl modem

i want to direct all traffic to specified ports (21,22,25,80, etc.) through
the eth1 interface, while feeding the rest of the traffic through the link
at eth2.

from the machine itself, i can use any of the interfaces to make a
connection e.g:
ssh -b 1.1.1.2 somehost
and
ssh -b 2.2.2.2 somehost
both work, on the remote host i can see the traffic goes through the
specific interface.
Unfortunately, that does not work for machines in local LAN connected to
eth0 masqeraded by the RTR. Actually all the traffic that leaves by the
interface with default gateway configured works ok, but the packets that
are routed to the other intarface when return are not de-masqueraded(?)
properly.
In other words:
assume eth1 has IPs: 1.1.1.0/29 with 1.1.1.1 being the DSL modem address
and 1.1.1.2 being ip assigned to eth1
assume eth2 has IPs: 2.2.2.0/29 with 2.2.2.1 being its DSL modem address
and 2.2.2.2 being ip assigned to eth1assume 1.1.1.1 (eth1) is configured as
default gateway

packet that goes from 192.168.10.1 to the 5.0.0.0 gets source address
translated at RTR to 1.1.1.2 and when a reply arrives at RTR eth1
interface, its destination is changed to 192.168.10.1 - so everything works
fine.

now, if i direct a packet (by using mark target at iptables chain and ip
rules) to send all traffic to port 2222 by eth2, suddenly the de-masquing
only half-works (which means it doesn't):
packet that goes from 192.168.10.1 to the 5.0.0.0 gets source address
translated at RTR to 2.2.2.2 (which is ok) a reply arrives at RTR eth2 with
the destination 2.2.2.2 - but then its somewhere lost in the kernel. I have
iptables logging the fate of this replay packet, and it is logged at table
mangle/PREROUTING (obvious) but then it does not arrive on neither
filter/FORWARD nor filter/INPUT nor even nat/PREROUTING chains

here is a part of the setup:

cerber:~/net/config_scripts# ip rule show
0: from all lookup local
4: from all to 192.168.0.0/16 lookup main
198: from all fwmark 0x100 lookup secondaryDSL
241: from 80.55.122.232/29 lookup primaryDSL
242: from 83.17.113.216/29 lookup secondaryDSL
32766: from all lookup main
32767: from all lookup default

cerber:~/net/config_scripts# ip route show table primaryDSL
1.1.1.0/29 dev eth1 proto kernel scope link src 1.1.1.2
default via 1.1.1.1 dev eth1

cerber:~/net/config_scripts# ip route show table secondaryDSL
2.2.2.0/29 dev eth2 proto kernel scope link src 2.2.2.2
default via 2.2.2.1 dev eth2

cerber:~/net/config_scripts# ip route show table main
1.1.1.0/29 dev eth1 proto kernel scope link src 1.1.1.2
2.2.2.0/29 dev eth2 proto kernel scope link src 2.2.2.2
192.168.0.0/16 dev eth0 proto kernel scope link src 192.168.192.1
default via 1.1.1.1 dev eth1 proto static src 1.1.1.2

kernel 2.4.28 with a few P-O-M addons and routing patches of Julian
Anastasov (rtmasq-2.4.20-2.diff and routes-2.4.27-9.diff)

any help would be greatly appreciated :-)

Marek



Relevant Pages

  • Re: Wireless interface stopped working in Etch
    ... The rt2500 modules seem identical on the working system and the fresh install. ... I have begun again with a new fresh install, so the wireless interface has been autmatically named 'eth1'. ...
    (Debian-User)
  • Re: [Fwd: FC9 Network Config]
    ... eth0: negotiated 100baseTx-HD, link ok ... eth1: no link ... eth2 is no link... ... Shutting down interface eth0: ...
    (Fedora)
  • Re: Wireless interface stopped working in Etch
    ... has been autmatically named 'eth1'. ... The interface on the working system remains 'wlan0'. ... AP with "iwlist wlan0 scan"? ... cells regardless of the interval between commands. ...
    (Debian-User)
  • Re: Re: Controlling eth0,eth1,... assignment order?
    ... wireless and ethernet access but interface naming is not important. ... eth0 external I/F and eth1 internal I/F. ... > interface and don't have a reason to care which card is designated eth0 ...
    (Debian-User)
  • physical vs. logical network interfaces
    ... eth0 is connected to my ISP and receives IPv4 address via DHCP, eth1 is a local network interface with static IPv4 address. ... the packets are seen as if coming on interface eth0; I think so, because POP3 service is then unreachable, while when using Router's eth1 static IPv4 address everything works fine; so I think they must be firewalled out. ...
    (comp.os.linux.networking)