Sharing 3G internet over Wi-Fi using HostAPd under Ubuntu Linux

How to use your 3G card on three machines at once.

[UPDATE: There is an easier way to do this now. Recent versions of Ubuntu have an option in the Network Manager GUI to share one internet connection over a LAN or WLAN. So the following notes are for background only.]

In case they are useful, I've pasted below this message the Linux config files needed to share a 3G internet connection over WPA Wi-Fi, by using Ubuntu Linux and HostAPd to make your own wireless access point.

I used this setup today to share a 3G connection from Linux to an XKryptor VPN laptop, and to an iPhone accessing the iTunes store. (Aside: the iPhone has its own 3G connection, but due to Apple / O2 policy, it refuses to download podcasts >10MB unless it thinks it's on Wi-Fi! Another solution for that might be to jailbreak the iPhone using Pwnage Tool, install HostAPd on it, then see if it will connect to itself...)

Anyway, here goes... Of course you'll need to tweak these files slightly to set your own ESSID and WPA passphrase. These files are taken from a laptop using an Atheros WLAN card and MadWifi drivers, running Ubuntu 7.04 Feisty Fawn. Your mileage may vary if you have a different configuration, but Ubuntu comes with commented templates for the various config files, so you can always read those as a starting point if something doesn't work.

Once hostapd is running, you can run hostapd_cli to monitor the clients.

You might want to disable any Linux network services before running this. My machine doesn't offer any open network ports, so I haven't bothered checking the iptables rules too closely - they just do the NAT stuff so that traffic from the Wi-Fi clients gets routed properly.