Raspberry Pi Static IP Address

UPDATE
– Things have changed a little with the new Jessie based image…
See my new tutorial for Jessie based systems

The tutorial below is suitable for all versions of the Raspberry Pi running a Debian based OS (Raspbian etc). Although the older Raspberry Pi’s such as Model A & Model A+ are near obsolete, the structure is the same. Tested on Raspberry Pi Model B, Model B+ & Raspberry Pi 2.

So you want to set your Raspberry Pi to have a static IP address. This is useful in so many ways whether it be for port forwarding, SSH logins or one of the many other reasons you want to have the same persistent address such as a dev server. The process described below is also the same for all debian based systems, including Ubuntu.

First of all some research needs to be done to determine current network settings so that the static address can be applied correctly. Run the following two commands

ifconfig
route -n

Console

Once the above has been run we can collect the following information
– Gateway
– Netmask
– Network
– Broadcast

Once our needed information has been gathered, network interfaces needs to be modified & networking restarted (pi rebooted). As we are working on a fresh install and to keep it simple, i am going to be using the packaged text editor – nano. Run the following command, making sure it is launched as root.

sudo nano /etc/network/interfaces

We then want to edit our primary interface so that it defines a static ip with the necessary configurations. Make sure you change the address to that of your desired static ip. Obviously make sure it is within the bounds of your network. In my case eth0 is my primary interface, however if for example your primary interface was a wireless connection, the following would be configured under wlan0 and so on.

iface eth0 inet static
address 192.168.1.199
gateway 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

Mine ended up looking like this…

Network/Interfaces

Make sure you then save and reboot (sudo reboot).
Done!

Leave a Reply

Your email address will not be published. Required fields are marked *