How to share quickly your connexion with your network - linux iptables ipforwarding

I have set a quick short iptables rules to share connexion over a trust network :

#first activate ipv4 forwarding
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'

#activate masquerade
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

Now on your host just change the default route :

sudo route del default
sudo route add default gw IP_OF_YOUR_FORWARDER_HOST

Have fun with Linux !

Short URL

Comments