Raspberry Pi – static WLAN IP Address
A Raspberry Pi is normally configured with DHCP. With DHCP your Raspberry Pi gets the IP address from your router, so it is possible, that your Pi have every time another different IP address. The advantage for this is that if you have many different devices that are using WLAN and not always online, the IP addresses are dynamically given. If you only have a small number of gadgets, more than possible IP addresses which is normal for a home network, than it would be a much better solution to use static IP addresses.
Use a static IP address
With Linux it is very easy to define a new fixed IP address. With WLAN it is a bit harder. I show you how to do this step by step. For this I expect that you already have a running Raspberry Pi which is connected to your WLAN network.
Configuration
You first step is to change the network configuration file. This has to be done with root rights:
sudo nano /etc/network/interfaces
You may find some lines here. Replace all lines with wlan0 or simply add this at the end of the file:
auto wlan0 iface wlan0 inet static address 192.168.1.10 netmask 255.255.255.0 gateway 192.168.1.1 wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
Save this and your are ready. We define a static inet (IPv4) interace for the first WLAN interface. We define the static IP address with the word address. Please change this with an IP address that is not yet used in your WLAN. Also we define a netmask and a gateway, which is the IP address of your router. The last line is important, without it it would not work.
If you have a wrong IP address after reboot, you may delete the first line where wlan0 is configured automatically.
Does not run, wpa-roam says, it will only run with inet manual!