Wednesday, April 29, 2009

HOWTO: Share internet connection (painlessly) from your Ubuntu machine over Wireless

Internet connection sharing (ICS) had been one of the insane things that I've always made use of, be it in Windoze or otherwise. And now with us using mobile broadband, me having my Acer Aspire One notebook installed with Ubuntu on it, it's time to take up the challenge again to get this up and running! No need for Wireless@SG anymore, I can BECOME Wireless@SG! :D

Problem was, after reading many Ubuntu forums and HOWTOs, trying out Firestarter many times (and I'm currently too lazy to learn to configure iptables myself manually), I was almost ready to give up, until I read up on ipmasq out of curiousity... You would need to use the terminal, so if you have an allergy to the terminal it'd be good to learn and overcome that first :)

If this was helpful to you, or if you have any questions, do leave a comment!

This HOWTO was done on the following:
  • Ubuntu Jaunty 9.0.4 UNR (Ubuntu Netbook Release)
  • Huawei E180 HSPA USB Modem
  • Acer Aspire One A150

Here's what you do:
1) Install dnsmasq and ipmasq
Run the following command in terminal:
sudo apt-get install dnsmasq ipmasq -y

2) Disable dnsmasq from autostarting
In your terminal, type:
sudo gedit /etc/default/dnsmasq

Look for the line that states "ENABLED=1" and change it to "ENABLED=0"

3) Kill off dnsmasq daemon
We don't want dnsmasq to be running as a daemon here, since NetworkManager tries to start it for shared connections.
sudo killall dnsmasq

4) Enable wireless
You should know how to do this if it's not already on...

5) Configure wireless
  1. Left click network manager applet in the top panel.
  2. Select "Create new wireless network".
  3. Type in the network name and change your security settings as needed.
This would tell NetworkManager to create an ad-hoc wireless network.

6) Check wireless config
  1. Right click network manager applet.
  2. Select "Edit Connections...".
  3. Go to the "Wireless" tab.
  4. Select your ad-hoc network and click on "Edit".
  5. Go to "IPv4 Settings" tab
  6. The method should be "Shared to other computers"
This is so that dnsmasq will run whenever this network is connected to, providing us a DHCP and DNS server for that ad-hoc network.

7) Configure ipmasq
In terminal, type:
sudo dpkg-reconfigure ipmasq
  1. Should PPP connections recompute the firewall? Yes
  2. Just press Ok
  3. When should ipmasq be started? After network interfaces are brought up

8) Connect internet facing modem connection if not already done so
For me I just select my service provider and Ubuntu "dials up" to connect

9) Run ipmasq to configure iptables
iptables configs does the actual routing, ipmasq helps configure iptables PAINLESSLY :)
From terminal, type:
sudo ipmasq

10) Get ipmasq to run whenever a network interface goes up or down
iptables configurations are not persistent, so I use ipmasq to autoconfig for me everytime a network interface goes up. Note that you can also use other methods to persist iptables. NetworkManager fires off scripts in /etc/network/if-up.d whenever an interface goes up, so let's tell it to run ipmasq too.
In terminal, type these commands:
cd /etc/network/if-up.d
sudo gedit config-iptables
Copy and paste the following into the editor, save and exit.
#! /bin/sh

Then in terminal again, make the script executable:
sudo chmod +x config-iptables
You will want ipmasq to autoconfig again when a network interface goes down, so run the following in terminal:
sudo cp config-iptables /etc/network/if-post-down.d

11) Connect client, start surfing :)
You're done! Now just get another wifi client to join in the ad-hoc network, and after it gets an IP automatically we should be good to go!

Sunday, April 05, 2009

Ubuntu on Acer Aspire One cannot see or join wireless network

In case anyone encounters the same problems, hopefully this saves the sanity of these people trying to troubleshoot this.

I'm using an Acer Aspire One A150, running Ubuntu Intrepid Ibex 8.10, madwifi-hal drivers as instructed here.

I was not able to see my wireless network even though it could detect and join other networks.  The problem was caused by the wireless network being set to a radio channel higher than 11.

Possible solutions:
1) (recommended) Change the wireless AP channel to between 1 and 11.
2) If (1) is not possible for you, follow squire_uk's forum post made on February 10th, 2009, 06:11 PM for his fix.