How to share your Internet connection on Ubuntu

For many moons ever since i started using Linux i have always wanted an easy way to share my internet connections between two computers. anyway i finally found a way to get it to work. Now i can share internet connection between my work laptop and my personally laptop.

Please while it might be possible on some other laptops. my laptop came with the PRO/Wireless 3945ABG and its impossible to share my internet over wireless because the current driver for my device doesnt support master mode which is what is needed for this to be possible. But with this guide it would be possible to share intenet via Lan. so if you get your intenet connection over wlan or a 3g modem or anything modem. it would be possible to share that same internet over Lan. Note if you got your wifi to work through ndiswrapper then we are also in the same shoes and sharing via wifi wont work. Infact this post is not about sharing your internet via wifi period.

Ok enough talk. To get started we would need tool packages. Firestarter and dhcp both can be installed with this command

sudo apt-get install firestarter dhcp3-server

Next we need to configure the internal Network Card that other computers get their internet from. In my case since the shaing computer gets internet from Wifi my internal network card (i.e the card other computers would be getting their internet from) would be eth0. we need to configure the card and assign a static IP address in a range that you will use for your internal network card. so rightclick on the Network manager applet and select edit

click the wired tab and select Auto eth0 (or the card of the particular card you want to coonfigure as the sharing interface) and click edit.

null

now select IPv4 Settings and choose Manual. now Add

and set it up to your preference. for example i set like this IP address to 192.168.0.1, and the subnet mask to 255.255.255.0. Leave the gateway empty.

Now we need to fix a problem where firestarter cannot locate the DHCP daemon script

so we open a terminal and run this command

sudo ln -sf /etc/init.d/dhcp3-server /etc/init.d/dhcpd

Next we configure the interface that DCHP will be listening to.

To do this we need to edit this file /etc/default/dhcp3-server

gksu gedit /etc/default/dhcp3-server

only variable in there by default is “INTERFACES”, which will have a null value. Set it to your internal network interface. For example:

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. “eth0 eth1”.
INTERFACES=”eth0″

save and exit

Now we run Firestarter Applications/Internet/Firestarter

A wizard should appear Select your Detected Device (Internet-connected) if your sharing computer gets its Internet via wifi then your external device would mostly be wlan0. if you are connected via a modem then it would be ppp0 device when it asks, and make sure to specify whether or not the address is obtained via DHCP. Click the “Forward” button, check the “Enable Internet connection sharing” box, select your internal network card,”Start firewall now” box, Then click on Preference and and Network settings.

“Enable DHCP for local network”. Drop down the “DHCP server details” and enter the range of IPs you would like for it to dynamically assign. Make sure they are in the same range as the static IP you set for your internal network card. You can leave the DNS field as “” Click “Forward”, check the “Start firewall now” box, and click “Save”.

“Enable DHCP for local network”. Drop down the “DHCP server details” and enter the range of IPs you would like for it to dynamically assign. Make sure they are in the same range as the static IP you set for your internal network card. You can leave the DNS field as “” Click “Forward”, check the “Start firewall now” box, and click “Save”.

At this stage am able to ping the from the other computer but am unable to access the internet. to fix this we need to add “net.ipv4.ip_forward = 1” to /etc/sysctl.conf

to /etc/sysctl.conf

so
gksu gedit /etc/sysctl.conf

and add this at the bottom

net.ipv4.ip_forward = 1
save and close.

now if all goes well you will be able to share your Internet to another laptop or computer. hope this helps some body

To share your internet using your wireless connection use this guide

Published by

Bobby

Name is Adesuyan Bobby and i work as a Linux system admin. A Lawyer by training, Geek at heart with passion for music, Hiking, Podcasts, Photography, books and most especially Free and Open Source Software.