LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Multi-NAT setup (https://www.linuxquestions.org/questions/linux-networking-3/multi-nat-setup-389755/)

okmyx 12-06-2005 06:42 AM

Multi-NAT setup
 
Any one have any info,links,etc on setting up a 'Many to Many No Overload' Multi-NAT router.

I have two networks that i wish to bridge with a NAT router, i want some PC to have access to services on the other network but they need specific IP addresses.

e.g.
172.16.46.1 <-> 200.0.0.1 (don't ask why it's a 200 range it a long story)
172.16.46.2 <-> 200.0.0.2
172.16.46.3 <-> 200.0.0.3
172.16.46.4 <-> 200.0.0.4
etc....

I far as my understanding goes it will require 2 network cards with multiple IP on each and then some clever IPtables rules to do the translation.

okmyx 12-07-2005 07:54 AM

Done some more research and found out the this is also called one-to-one Nat (multi-nat is a netgear name).

So it should be possible to do using just iptables rules. Any ideas?

fr_laz 12-07-2005 01:28 PM

hi...

you're right, for a single host (with eth0 your interface to internet), it goes like this:
Code:

iptables -t nat -A PREROUTING -i eth0 -d 200.0.0.1 -j DNAT --to-destination 172.16.46.1
iptables -t nat -A POSTROUTING -o eth0 -s 172.16.46.1 -j SNAT --to-source 200.0.0.1
ip addr add 200.0.0.1 dev eth0

Note that i precised the interface on the 2 iptables rules to avoid that traffic from 172.16.46.1 to the gateway itself (like if you ping your gateway as an exemple) be nated as well.

First line do the translation on the way from internet to LAN
Second line do it the other way around
Third line creates an alias on eth0 so that your gateway answers to arp queries and accept ip traffic to this IP as well as to its own.

okmyx 12-09-2005 09:30 AM

Excellent...thank you for your help.

With a little tweaking (coz im using two network cards) i have got this working perfectly.

After managing to pull this off I can no longer class myself as a newbie, but still a long way from guru.


All times are GMT -5. The time now is 01:51 AM.