Cluster der kan alt/Routning og NAT

From Teknologisk videncenter
Jump to: navigation, search

Routning & NAT

Configuring NAT (Sharing Internet)

Start Routing

For this, we do not need to install anything new. Everything is right there but is currently disabled. First, edit /etc/sysctl.conf. Find this:


Uncomment it by removing the #. Now forwarding is enabled in the system kernel.

Start routing without a reboot

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

This will enable it without a reboot.


iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

What this does is make a NAT rule for post-routing. It sets the eth0 as the output card (The one out to the internet) and sets source to it's own IP through MASQUERADE. Then write: Just to be sure, save it.

iptables-save > /etc/iptables.rules

Now that it’s saved we need to load the iptables.rules on starting the network:

edit the file /etc/network/interfaces

# The extended interfaces
auto eth0
iface eth0 inet dhcp
pre-up iptables-restore < /etc/iptables.rules
post-down iptables-restore < /etc/iptables.rules

Test it out on your other client.