Setting Up a Static IP Address for the Raspberry Pi

Static IP Address    Send article as PDF   
When you wish to log in to your Raspberry Pi remotely, you will need the IP Address of the Raspberry Pi. By default, the Raspberry Pi will be given an IP automatically by the router (called Dynamic IP and denoted by DHCP) when you connect to a network. However, as the name suggest, the IP can change whenever you remove the Pi from the network or turn it off.

Having a static IP isn’t essential, however it will make repeated access to the Raspberry Pi via SSH and VNC much simpler, as you will always know that the Raspberry Pi has the same address every time.

This guide also assumes that you’ve connected your Pi to a network via Ethernet and you are using the official Raspian OS or NOOBS distribution installed. Logging into your Pi remotely for most tasks, I recommend it’s easiest and fastest to use Ethernet to access the internet!


Boot into Raspian and log in (Username. pi, Password. raspberry), this will all be command line stuff, so no need to log in to the GUI if X isn’t started automatically.

Have a pen and paper at the ready! . . .

First, we need to list the network interface we currently have available:

cat /etc/network/interfaces

Static IP 01

The line . . . .

iface eth0 inet dhcp

Implies that we’re currently getting the IP address via DHCP, meaning it’s being dynamically registered by the router. This is what we need to change!

Gathering Network Information:

Fist of all we need to retrieve some information from our router and the Raspberry Pi. First we need to run the following command to retrieve the first part of the information.



This reveals your router information, the bit you want is after eth0 (the ethernet connection). . . .

eth0 Link encap:Ethernet HWaddr b8:27:eb:cc:03:0e

inet addr: Bcast: Mask:

Write down the following information. . .

  • inet addr – (Pi’s Current IP Address)
  • Bcast – (The Broadcast IP Range)
  • Mask – (Subnet Mask Address)

We need a little more information before we proceed, so run the following command.

netstat -nr

Static IP 03

We need:

  • ‘Gateway’ Address –
  • ‘Destination’ Address –

Editing Network Configuration:

We now need to plug this information into the Raspberry Pi’s network configuration file using a text editor. For this use the nano text editor as follows. . .

sudo nano /etc/network/interfaces

Static IP 04

Simply change the line that reads:

iface eth0 inet dhcp


iface eth0 inet static

Then directly below this line enter the following (Please Note. You will need your own addresses we gathered in Part B, more details below). . . .


To clarify what each part means. . . .

address – The address you want to give your Pi, this can be any IP in the network range, but it’s usually advisable to go higher rather than lower, or you could end up logging different devices to the same IP! I’ve selected, as address (denoted by ‘inet addr‘), but this can be any IP address from the range10.0.0.1 to

netmask – The ‘Mask‘ address we wrote down earlier.

network – The router IP address, this is the ‘Destination‘ Address was found earlier. You can also grab this off your router, it will say on the side somewhere.

broadcast – The ‘Bcast‘ address we wrote down earlier.

gateway – This is the ‘Gateway‘ address we found earlier.

Static IP 05

So, it should look something like the above, but with your values!

Note that in the above example I also set the Wi-Fi IP to the same as the Ethernet for simplicity as this Raspberry Pi runs my BrickPi Interface Board normally.

Remember to save before exit, CTRL+X (exit) then yes to save changes!

Check the New Static IP Configuration:

We will now need to reboot the Raspberry Pi for the changes to take effect.

sudo reboot

Log back into the Raspberry Pi and run


Your new Network Setting be should revealed.

Static IP 06

To double checks all is working as it should, ping your ‘Gateway‘ Address. . .

ping -c 10

(the -c 10 command simply denotes that you want to ping it 10 times, if you forget to add this, it will ping the address continuously. To stop it press CTRL+C)

Static IP 07

The should ping successfully and all packets should be received back if all you changes have worked. If something’s not right double check through all your IP addresses, and make sure you’re pinging the right address too. Remember you can always revert back to DHCP by reversing the steps. The ‘network‘ router IP address can sometimes be a little problematic, so check that if you’re still having issues!

Hopefully however, your Raspberry Pi is now set up with a static IP address making SSH and VNC access a lot simpler….

Previous Post

Remotely Control the Raspberry Pi using VNC

Virtual Network Computing (VNC) is a graphical desktop sharing system that uses the Remote Frame Buffer protocol (RFB) to remotely control another computer. It transmits the keyboard and mouse events ... Read more

Next Post

BrickPi: Raspberry Pi for Mindstorms Robots

BickPi is a system that converts Raspberry Pi into a robot.  The project is a board and case that connects LEGO® Mindstorms Sensors, motors, and parts to turn your credit ... Read more

Short URL:

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do NOT follow this link or you will be banned from the site!