how to share internet to LAN via NAT server on ubuntu

Chan Chung Hang Christopher christopher.chan at bradbury.edu.hk
Sun May 10 00:46:05 UTC 2009


Jaspreet Singh wrote:
> hi i just got a problem, one of my system has 4 nodes, on the main
> node(ubuntu) it has Internet connection, now the situation is how to share
> that internet to othr 3 nodes on local lan. help would be apperciated...
>
>   


Do you have different subnets on the other three interfaces?

Do you have a static ip address on your Internet facing interface?

One thing you will have to do regardless is edit /etc/sysctl.conf.

Uncomment the line: #net.ipv4.ip_forward=1 (Delete the #)

This will ensure that on every reboot, packet forwarding will be enabled.


You can add these commands to /etc/network/interfaces (assuming you have 
no other filter rule loading mechanism)
       Under the section for the interface facing the Internet:
       1) Static address
       post-up /sbin/iptables -t nat -A POSTROUTING -o $IFACE [-s 
internal_subnet] -j SNAT --to-source $IF_address

       2) Dynamically assigned address
       post-up /sbin/iptables -t nat -A POSTROUTING -o $IFACE [-s 
internal_subnet] -j MASQUERADE

Remove the square brackets and replace 'internal_subnet' as necessary, 
one line each per subnet. Or you can just not limit natting to any 
internal subnet and nat any packet that goes out on the Internet 
interface by not specifying any source address.




More information about the ubuntu-users mailing list