Sunday, July 8, 2012

How to share 3G Internet connection on Ubuntu

I've been looking everywhere, reading tens of articles on how to share internet connection using WiFi via my 3G internet connection. I wanted connect my iPhone 3GS to Ubuntu Wifi such that I can download apps larger than 20MB easily. Finally, I found this post in ubuntu forum that fixed the my issue. Things were straight forward, so nothing big to worry. Though the post is for 9.10, it worked in Ubuntu 11.10 for me. http://ubuntuforums.org/archive/index.php/t-1384085.html

I'd like to keep things in one place for later reference, so I'm stating it here with some customizations.

I tried this with Huawei E173 3G modem, and the Wireless connection of my laptop.
Here,
3G modem -  accesses internet.
Wireless (WiFi) AdHoc network - for sharing the internet connection with other computers.

You'll need only need Firestarter. The Operating System I tested is Ubuntu 11.10 (Oneiric Ocelot).

Type in the terminal
`sudo apt-get install firestarter`


This guide assumes a basic understanding of ip addresses...gateways dns servers etc.

This solution does not provide dhcp ....but hey I don't want that anyway.

Make sure your 3G modem, and wireless card already works (may be on windows or OS X).... if not install their software and activate your card...verify it works etc...

Now plug the card into the ubuntu box and set it up with network-manager. Right click the connection and select new cdma modem (or similar) and input your details as neccesary. This is for the MODEM.

Once connected unplug any ethernet...turn off any wifi and verify you have internet access.

Then right click the network manager icon and select "Create New Wireless Network" to create an ad-hoc wifi connection. There, given a network name you prefer (say MyWifi). Set Wireless security to "WEP 40/128-bit...", and give a 5 letter key/password (0-9A-Z).

Now, go to network-manager -> "Edit Connections". In the Wireless tab, you'll find your wireless connection (MyWifi). Select it, and click on edit.

Then click ipv4 settings tab

Change from dhcp to manual and enter the following details

address = 192.168.13.1
netmask = 255.255.255.0
leave gateway blank

That's done. Now, start firestarter. 
`gksudo firestarter`

Use the wizard and select ppp0 as your internet device. You may want to set `IP Address assigned via DHCP` for this connection if that's the case. Check with your ISP for more info.

Select connection sharing and then use wlan0 as your sharing device. This is the your wifi network device. We don't need dhcp here. 

Connect to MyWifi connection, and to your 3G broadband connection.

Now, start firestarter firewall...

Now configure your iPhone/another computer to use this gateway in Static tab ..

set your ip address to be 192.168.13.101
netmask 255.255.255.0
router (or default gateway) 192.168.13.1

IMPORTANT you need to enter DNS servers... I used Google DNS. You may use openDNS if you need. The Google DNS I set was.

8.8.8.8

If you really want OpenDNS, register for their free service, and use these DNS addresses. 208.67.222.222,208.67.220.220

Thats it!

Save everything and you should have a working internet connection that is shareable! obviously everyone needs their own ip address and setup is a little cumbersome but hey it works!

if you want dhcp you can probably get this to work using ubuntu server, wvdial, and the great help by googling ubuntu easyrouter.

but hey this works for me....and I like having network manager deal with the usb modem.

Have a good day. Welcome your thoughts/questions in the comments section. :-)