Linux Simple NAT

From D3xt3r01.tk
Jump to navigationJump to search

WHAT

I'm trying to explain how a simple network can share a connection using a linux router. The same router can also serve file sharing, mail server and other stuff to the network.

HOW

1) load the ipt_MASQUERADE . Depending on the distro, this could be built in, already loaded or not available. Try continuing even if it fails.

modprobe ipt_MASQUERADE

2) Be sure to flush all the rules in iptables. You can apply yours after you see NAT is working.

iptables -F; iptables -t nat -F; iptables -t mangle -F

3) Enable ip_forwarding in the kernel

echo 1 > /proc/sys/net/ipv4/ip_forward

4) Forward your ips to the one on eth0

iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j SNAT -o eth0 --to 89.46.240.254

LINKS

Masquerading made simple