LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Help with iproute2 (https://www.linuxquestions.org/questions/linux-networking-3/help-with-iproute2-322845/)

warwolf 05-12-2005 03:06 PM

Help with iproute2
 
I have a linux machine i want to use as a nat router got 2 nic:s one for my internal lan (eth1) with ip 192.168.0.1/24 it runs a dhcp server so all computers on my lan get an 192.168.0.x address. The other card (eth0) is connected to my dsl-modem and get it's ip 'y.y.y.y' by dhcp. No i want to nat all my computers inside this lan.
As i understand i should use
"ip route add nat" and "ip rule add nat" then flush the cache to be sure it use my new routings, but for some reasons i can't get this to work.

/thanks in advance - WarWolf

fr_laz 05-13-2005 09:25 AM

Hi,

Usually, people use iptables to configure NAT...
rules looks like :
WAN_IFACE = ppp0
SOURCE_IP = 192.168.0.0/24
PUBLIC_IP = xxx.xxx.xxx.xxx

iptables -t nat -A POSTROUTING -s $SOURCE_IP -o $WAN_IFACE -j SNAT --to-source $PUBLIC_IP
or
iptables -t nat -A POSTROUTING -s $SOURCE_IP -o $WAN_IFACE -j MASQUERADE

The second one is to be used when you get a dynamic IP from your ISP : it automatically nats the pakets to the IP of the output interface.

For more info on iptables, have a look at http://www.linuxsecurity.com/resourc...-tutorial.html

see you...


All times are GMT -5. The time now is 10:37 PM.