Difference between revisions of "Simple internet sharing with NAT linux"

From Kenneth Noyens
Jump to: navigation, search
 
Line 13: Line 13:
 
</pre>
 
</pre>
  
Or make a script that executes before netwerk bring up: <br>
+
Or make a script that executes before network bring up: <br>
  
 
Make a file /etc/network/if-pre-up.d/routing:
 
Make a file /etc/network/if-pre-up.d/routing:

Latest revision as of 10:46, 8 April 2010

activate ip forward:

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

Because changes is /proc/ are not saved and will be lost at every reboot you can edit /etc/sysctl.conf:

net.ipv4.ip_forward = 1

Now all packets are forwarded without NAT, to enable NAT enter this command:

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

Or make a script that executes before network bring up:

Make a file /etc/network/if-pre-up.d/routing:

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

Make the script executable:

chmod a+x routing