Thio4linux

– Open Source World –

Share internet connection on Linux

Posted by thio4linux on October 14, 2007


How to connect 2 linux pc with a sharing connection

you should have 2 network interfaces:
– one directly connected to internet (i use ppp0 in this tutorial)
– and the other for the connection of the 2 pc (i use ethernet eth0)

on the pc connected to internet (the “server”):
sudo ifconfig eth0 192.168.100.1 up
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
sudo sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”

and then look at the resolv.conf file: gedit /etc/resolv.conf

on the other pc (“client”):
sudo ifconfig eth0 192.168.100.x (substitute x with a number from 2 to 255)
sudo route add default gw 192.168.100.1

then open the resolv.conf file and add here the address that you have find on the server pc.
enjoy your shared connection!!!

One Response to “Share internet connection on Linux”

  1. artiomix said

    Here is detailed article on how to set up NAT gateway with Linux and ipables. Hope it would be useful!🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: