A big part of Raspberry Pi's usefulness comes from its size. A lot of those benefits get lost when you need an external display and keyboard (and mouse maybe) to actually do anything with it. In this post I'll quickly cover how you can set up your Raspberry Pi (A, but B would work too, it'd actually be a little bit easier) to automatically connect to your wireless network and obtain a static IP. All you need is a WiFi-dongle.
Because the Raspberry Pi A only has one USB-port, there'll be a lot of USB switching.
Start by booting the Raspberry Pi, connected to a display and a keyboard. Open up the terminal and edit the network interfaces file:
$ sudo nano /etc/network/interfaces
This file contains all known network interfaces, it'll probably have a line or two in there already.
Change the first line (or add it if it's not there) to:
Then at the bottom of the file, add these lines telling the Raspberry Pi to allow wlan as a network connection method and use the
/etc/wpa_supplicant/wpa_supplicant.conf as your configuration file.
iface wlan0 inet dhcp
iface default inet dhcp
(ctrl-X, then type Y to quit and save)
The next step is to create this configuration file.
Open up the wpa_supplicant.conf file in the editor.
$ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Again, some lines might already be present, just add the following.
The other parameters are network specific, I can't tell you what you need. If you boot Raspbian to desktop, you can launc the wpa_gui (WiFi config) application and click 'Scan'. You'll find a list that has your network too with all flags you need. To do this on a RPi A you'll have to disconnect your keyboard and connect your dongle once the scanning list is open.
protocould be either
key_mgmtcould be either
WPA-PSK(most probably) or
pairwisecould be either
auth_algis most probably
OPEN, other options are
Reboot the Raspberry Pi and it should connect to the wireless network. If it doesn't, repeat above steps or get help from an adult.
Since the goal of this tutorial is to be able to work with the RPi without external keyboard or display, you want to be ssh into it. The best way is to make sure it'll always have a static IP on your network.
Doing so is simple. Open the
/etc/network/interfaces file again and add the following changes:
iface wlan0 inet dhcp into
iface wlan0 inet static. This changes the wlan0 interface from DHCP to static.
Add the following lines before the wpa-conf line:
address 192.168.1.155 # Static IP you want
gateway 192.168.1.1 # IP of your router
The Raspberry Pi will still be able to connect to the internet.
With these changes you'll be able to always connect to your Raspberry Pi over your wireless network via ssh at the same, static IP. This means you can disconnect keyboard, mouse and display and have it plugged in a wall socket, anywhere, taking almost no space.
As an overview, my interfaces- and wpa_supplicant-files: