[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: NAT problems



Tobias Geijersson <tobias.geijersson@xtnd.com> writes:

> The problem is that when I add the rule for masqurading it translates
> all 192.168.10.1/24 to eth0's 192.168.2.254 before routed to my ip
> provider, and that adress is a private one and will not work!
> 
> How do I solve this in kernel 2.2?

I'm not sure I entirely understand your dilema but it should be possible
under 2.2.  You need to use the iproute2 package and have an appropriately
compiled Linux kernel.

I've used policy routing in a few places and it enables you to masquerade/NAT
as any address you like.

ip rule add from 192.168.10.0/24 nat 1.2.3.4

If you router's default gateway is on an interface other than the one to
which you wish to NAT then you may have to set up a custom routing table for
that network.

ip route add default via 1.2.3.1 table 192
ip rule add from 192.168.10.0/24 lookup table 192 nat 1.2.3.4

This has the effect of routing all your externally destined packets arriving
from the 192.168.10.0/24 network to your 1.2.3.1 router with a source address
of 1.2.3.4 ... 1.2.3.4 must actually be an address assigned to you Linux box.

Note you will probably have to add throw routes for your local networks to
the new routing table you created so that local traffic works correctly.

We use this in a location with 4 different Internet connections (DSL/T1) and
route different private IP servers out the different gateways ... it works
very well.

-- 
fraser campbell <fraser@starnix.com>                          starnix inc.
tollfree: (905) 771-0017                        thornhill, ontario, canada
http://www.starnix.com/             professional linux services & products



Reply to: