Building a NAT router?

shrek-m at gmx.de shrek-m at gmx.de
Wed Sep 24 12:28:53 UTC 2003


Martin wrote:

>Hi,
>
>my Severn box has 2 NICs and I would like to use it as a router for my
>DSL connection. Unfortunately I have no clue how to configure NAT (and
>portforwarding) :( I managed to get the box on the net using the
>Internet Configuration Wizard and I can ping the second NIC
>(192.168.1.1) from my other machine (192.168.1.2) but I still have to
>find out how to NAT and forward ports. So if anybody knows if/how I
>can do this with redhat-network-config or any other way I would be
>very greatful for any advice.
>

eg.
eth0 = ppp0
eth1 = 192.168.1.1

forwarding is enabled?
# sysctl -a | grep ip_forw
net.ipv4.ip_forward = 1

your clients:
standard-gateway?
dns-server?


eg. masquerade
only  smtp,dns,http,pop3,https

iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -p tcp -m 
multiport --dport 25,53,80,110,443 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -p udp -m 
multiport --dport 53 -j MASQUERADE


eg. portforwarding
port ppp0:2222 --> lan:22

iptables -t nat -A PREROUTING -i ppp0 -p tcp -m tcp --dport 2222 -j DNAT 
--to-destination 192.168.1.2:22


$ man adsl-setup
$ man sysctl
$ man iptables
http://netfilter.org
$ vi /etc/services
...

good luck


-- 
shrek-m





More information about the test mailing list