Sharing Internet connection on Linux

As I told in some previous post I’m using 3G modem on Linux to access the Internet in my computer, but today I decided to share my internet connection with my sister, yes her computer runs Linux too.

When the 3G connection is successful Linux creates a “ppp0” interface. Then I connected ethernet cross-cable between my computer and her computer. These are the steps to share connection:

On my computer (where the 3G modem is connected):

# ifconfig eth0 192.168.0.1 up
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# echo 1 > /proc/sys/net/ipv4/ip_forward

On her computer I just run:

# ifconfig eth0 192.168.0.2
# route add default gw 192.168.0.1

And I added in the /etc/resolv.conf:

nameserver 200.169.117.22
nameserver 200.169.119.22

Done!

Update: In some new Ubuntu versions you need to disable the ufw: $ sudo ufw disable. Other important tip on Ubuntu network config (nm-applet of NetworkManager) there is an option to share internet too.

3 thoughts on “Sharing Internet connection on Linux

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 )

Connecting to %s