In an effort to liberate my Raspberry Pi, I finally caved in and bought a wireless USB adapter. Getting it up and running was not as difficult as I expected.
The Raspberry Pi wiki has a list of verified peripherals – I found the Belkin Surf at Dion Wired for R399.
After mucking about with the
/etc/network/interfaces file for a while, the wireless adapter was visible in
ifconfig but not picking up an IP. I eventually resorted to the following lines in the
First, tell it which wireless network to connect to – replace Airport with the name of your wireless network, and put it into Managed mode:
sudo iwconfig wlan0 essid "Airport" sudo iwconfig wlan0 mode Managed
My Raspberry Pi runs headless, so I want to hard-code the IP that it will have on my network
sudo iwconfig wlan 192.168.1.227 netmask 255.255.255.0 up
Then add the IP of your router or ADSL modem so that it can find it’s way out of your network:
sudo route add default gw 192.168.1.254
If you don’t know what gateway IP your network has you can find out on a machine that has DHCP’d an IP by using the
route -n on a Linux based machine or
netstat -nr | grep default on a Mac.
This next bit is a bit of a hack, but the
/etc/resolv.conf get’s overwritten each time you bring up the networking. I just use sed and replace the
nameserver entry with the one I want:
sudo sed s/nameserver.*/nameserver 126.96.36.199/g -i /etc/resolv.conf
I could have wasted more time trying to get the /etc/network/interfaces syntax working, but this does the job and let’s me get on with other things.