Re: Linux 2.2, iproute2, policy routing AND masquerading...

From: timur@pink.phys.spbu.ru
Date: Thu Mar 02 2000 - 14:17:36 EST


On Sun, 27 Feb 2000, Alexander List wrote:

> Hello,
>
> I have a problem ;-) and couldn't find an answer in the docs, newsgroups
> or mailing list archives so I'm trying this list as a last resort...
>
> The following is symbolic, so you can get the picture...
>
> We have two companies sharing LAN infrastructure and ONE firewall, but we have
> two different ISPs. Traffic from company1 should go out via ISP1, traffic from
> company2 should go out via ISP2. Of course, we have only one IP address per
> ISP because we are two very small companies, and of course no chance to get a
> routing protocol like RIP or so.
>
> I read somewhere that Linux 2.2 supports policy routing, so I gave it a try...
>
> # first, switch on interfaces ;-)
> ip link set lo up # loopback interface
> ip link set eth0 up # interface to company1 LAN
> ip link set eth1 up # interface to company2 LAN
> ip link set eth2 up # interface to external LAN (ISPs)
>
> # loopback
> ip addr add 127.0.0.1/8 dev lo
>
> # private IP network of company1
> ip addr add 192.168.10.1/24 dev eth0
>
> # private IP network of company2
> ip addr add 192.168.20.1/24 dev eth1
> # don't know if that route is necessary, but it won't break anything
> ip route add 192.168.20.0/24 dev eth1 table company2
>
> # routing to ISPs
> ip addr add 1.2.3.4/24 dev eth2 # connection to ISP 1
> ip route add 1.2.3.0/24 dev eth2
The above line is not needed

> ip route add 0.0.0.0/0 via 1.2.3.1 # default route for company1
>
> ip addr add 2.3.4.5/24 dev eth2 # connection to ISP 2
> ip route add 2.3.4.0/24 dev eth2
Not needed as well.

>
> # now I want to use routing table company2 for company2
> ip rule add from 192.168.20.0/24 table company2 priority 20
>
This is not what you want. According to manual you should write
        ip rule add from 192.168.20.0/24 nat 2.3.4.5 table company2 prio 20
and then
        ip rule add from 192.168.10.0/24 nat 1.2.3.4 [table main] prio 30
         
> # and of course another default route for that company
To be accurate I would rather inserted here
        ip route add 2.3.4.0/24 dev eth2 table company2

> ip route add 0.0.0.0/0 via 2.3.4.1 table company2
>
> # and now my problem starts:
> # the iproute2 docs say that route NAT in Kernel 2.2 is NOT a
> # replacement for IP masquerading, so I tried ipchains
>
Strange. NB on page 51 of "IP command reference" says:
"The exception is when the address is a local address of
this router ... and masquerading is configured in the
kernel. In this case router will masquerade packets as this
address."
Or you mean that this feature is broken?

                                                Timur.

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.rutgers.edu



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:27 EST