How To Assign A Static IP to The Raspberry Pi

Normally when devices connect to the network they are assigned IP address by the router which does so sequentially (in the order of devices being connected) or randomly. The same goes with your Raspberry Pi. But if you wish to use your Pi without a display (for e.g. via SSH, as a Web Server, or any remote project) then letting the router assign a IP address is generally not a good idea. In such cases you should give your Pi a static IP so that it is always accessible on the same address. That is what we are going to do in this Instructables.

Watch the video above or continue reading for Step-By-Step Instructions.

Watch The Video HERE

Step 1: Getting Ready

What You Will Need:

– Raspberry Pi

– A MicroSD card with Raspbian installed.

 To see how to install Raspbian read This Instructables or watch This Video

– Connection to the router (The router doesn't need to have a internet connection).

– A USB keyboard and Mouse (not needed if you want to SSH into the pi)

– A Display (not needed if you want to SSH into the pi)

– A power adapter.

Setting Up The Pi:

– Connect all the peripherals to the Pi and connect power.

– Log in and open command line or the terminal (if you are in the desktop enviornment).

– Proceed to the next step.How To Assign A Static IP to The Raspberry Pi

Step 2: Gathering Intelligence

Before we change any settings on the pi, we need to collect some information regarding our network.

– In the command line type the following command and hit enter.


– From the info that comes up, note down the following things:

-> inet addr

-> Bcast

-> Mask

– When you have got all this information, you need even more information. Enter the following command and hit enter

netstat -nr

– From the table that comes up note down the following:

-> Destination

-> Gateway

This is what I got:

  • inet addr :
  • Bcast :
  • Mask :
  • Destination :
  • Gateway :

These numbers will most probabaly will be different for you so don't copy mine by mistake.

After you have got all this, you can proceed to the next step.

Step 3: Execution

Now we can finally get a Static IP.

Enter the following command and hit enter.

sudo nano /etc/network/interfaces

A file editor will open up.

– In the third line, β€˜dhcp' means that we are currently getting our IP address from the router.

iface eth0 inet dhcp

– In this line replace β€˜dhcp' with β€˜static'

iface eth0 inet static

– Now in the line below this you need to write type the following

<p>address [your inet addr]<br>netmask [your mask address]
network [your destination address]
broadcast [your bcast address]
gateway [your gateway address]</p>

Finally your whole document will look something like this:

<p>auto lo</p><p>iface lo inet loopback
iface etho inet static
gateway</p><p>allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp</p>

Be careful to enter YOUR addresses, don't use my numbers by mistake

– Save the file by pressing cntrl + X , then Y , then enter.

– Restart the pi by running the command.

sudo reboot

– After the reboot is complete, you should have a static IP address!!!!

Your Static IP will be the inet address that you noted down earlier.FJ53LPGICG2B3PV.LARGE.jpg

Step 4: Alternative

While the above mentioned method will certainly work in almost all scenarios irrespective of your router and network, a better method to assign a static IP would be to do it through your router settings.

All the routers, even of different models from the same company, have very different setting layout and option availability. Thus there cannot be a unified guide for all the routers. You should check out the user manual that came with your router to see how to assign a static IP through your router. Doing so will require you to know the MAC Address of your Pi. You can know the MAC address by running the command β€œifconfigβ€œ, in the first line, the HWaddr if your MAC address.

You need to assign the static IP to the MAC address of your Pi.

Thanks for reading this Instructables!!

Take a look at my other Instructables.

Checkout the youtube video for clearer instructions here

You can follow me on Twitter

Also checkout my Youtube Channel

You can even follow me on Google+


For more detail:How To Assign A Static IP to The Raspberry Pi

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

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

Scroll to Top