this is my first post in these forums, but it's about a subject I spent a couple of evenings trying to get to work:
How to setup my Raspberry Pi's wireless network connection to use a static IP address.
I searched around quite a bit, but couldn't find anyone that could tell me how to do it. So, with a bit of experientation and by using different bits of tutorials I managed to get it working.
I'm using the latest Rasbian "Wheezy" image, 2012-12-16-wheezy-raspbian.
I'm going to make several assumptions that you have a supported wifi dongle (you can check the list here: http://elinux.org/RPi_VerifiedPeriphera ... dapters%20 - I use a TP-Link TL-WN723N which is a cute little dongle (white with an under-the-skin green led activity light) and nice and cheap at £6.96 from the Dabs ebay store), it's plugged into your RPi, and you have basic linux skills (like I do) so know your way around the terminal. I'm also assuming that you have a basic understanding of IP addresses, and how to configure your router.
After setting up your SD card with the image and booting your RPi for the first time and being presented with the raspi-config menu. You can get this menu back at any time from the command line using
Code: Select all
sudo raspi-configAfter the obligatory reboot, open the WIFI Config GUI (there should be a shortcut on the desktop, or it's listed as in the menu as Internet>wpa_gui or Other>wpa_supplicant user interface).
Click on Scan and look for your wireless network in the results. Double click the entry for your wireless network and enter your PSK (pre shared key) in the field provided (all the other elevant fields should have auto-populated). At the bottom of the window is a field for IDString under Optional Settings. Enter a string here that you can remember and doesn't contain any spaces (I use 'home_static').
Now we need to tell your RPi what static IP address to use for this network.
For that, we need to edit the /etc/network/interfaces file.
I use 'vi' for my command line editing. It can be a little fiddley but a good list of the commands can be found here; http://www.cs.colostate.edu/helpdocs/vi.html.
To open the file for editing, open an LXTerminal session (again, there should be a shortcut on the desktop, or else it's under Accessories>LXTerminal or Other>LXTerminal in the menu), and type:
Code: Select all
sudo vi /etc/network/interfacesCode: Select all
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcpCode: Select all
iface home_static inet static
address 192.168.0.53
netmask 255.255.255.0
gateway 192.168.0.1Once you've saved the file, you need to restart your network services. I've found with the RPi that simply restarting the network services on their own is not enough, so I usually carry out a full reboot. It doesn't take long.
This can be done for multiple networks, and you can have more than one entry for each network by giving them a different IDString (not sure why you'd want to though) and if you don't add an entry in /etc/network/interfaces then it will use DHCP as default.
For info, the wireless network information is stored in /etc/wpa_supplicant/wpa_supplicant.conf and you can manually edit it using
Code: Select all
sudo vi /etc/wpa_supplicant/wpa_supplicant.confHope this helps and saves a few people a couple of evenings of head scratching (although that's half the fun, right?)...
Steve
