Static IP Address Raspberry pi

Topic: Static Ip Address Raspberry pi

This is quite a common task, but sometimes it’s not easy (especially first times) to remember these settings. So for me and others who need a static ip address on a raspberry pi running Debian, here is how:

How to setup a static IP Address on Raspberry-pi  running Raspbian or Debian

This will involve 2 files:

  • /etc/network/interfaces
  • /etc/resolv.conf

Actually /etc/resolv.conf is not directly involved into changing IP address, but it is useful right after having done it because you used to get also DNS server related information during DHCP request made by the client station. Anyway it is better to know it, because if you changed the network configuration to have a fixed static IP address and you can’t resolve any name, that’s one of the possible reasons.

Open the file /etc/network/interfaces with nano

sudo nano /etc/network/interfaces

It will probably look like this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

We need to modify the “dhcp” under the “eth0” configuration and change it to “static”, then we need to add right after the modified line the following parameters:

  • address (in the form of an IP v4 address ex.
  • netmask (in the form of dotted IP v4 netmask ex.
  • gateway (in the form of an IP v4 address ex.
  • network (in the form of an IP v4 network address ex.
  • broadcast (in the form of an IP v4 broadcast address ex.

So you should end up with something similar (except for the ip addresses unless you are using these very classes):

auto eth0
iface eth0 inet static

This can be applied also to a Wifi network adapter as long as it is recognized by the system and correctly configured by you.

Now edit your /etc/resolv.conf in order to add some functional dns information. Personally i often use the Google public dns servers because they are so easy to remember:


So, now open /etc/resolv.conf in nano by typing into a terminal

sudo nano /etc/resolv.conf

and just add the following values:


Now you have to reload network settings by these 3 concatenated commands:

sudo ifdown eth0 && sudo service networking restart && sudo ifup eth0

Then you should try you new configuration by pinging for example

pi@raspberrypi ~ $ ping
PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=48 time=21.7 ms
64 bytes from ( icmp_req=2 ttl=48 time=14.1 ms
64 bytes from ( icmp_req=3 ttl=48 time=15.1 ms

That should be all about this. If you want to know something more specific, please don’t hesitate writing.

Also you maybe want to take a look on How to configure wifi on raspberry or how to stream a video from raspberry

(Visited 29,828 times, 1 visits today)

Author: Giuseppe Urso

Giuseppe lives in Haarlem now with his shiny dog, Filippa In 1982 received his first home computer, a Commodore 64, followed by Datasette and a 1541 Floppy Disk Drive. In 1999 he installed his first Linux distro (LRH6). In 2006 he switched to Debian as favourite OS. Giuseppe Urso actively sustains the Free Software Fundation and his founder Richard Mattew Stallman, he speaks to people trying to convince them to join the fight now, and about how important is to use Free Software only. He has a job as Infra Specialist at Hippo Enterprise Java Cms an Open Source Enterprise class Content Management System, one of the coolest company ever, in Amsterdam. He's always ready to install Debian on other people computers for free.

4 thoughts on “Static IP Address Raspberry pi”

  1. I have problems with my RPi, I configured the IP address following the procedure that you describe and now I do have a connection to Internet and it´s working fine, the connection to internet is wired, but I cannot use the SSH or even ping the IP of my RPi because it says that could not find the IP, I tried to ping from the RPi to another device on my home network but I could not, please help!

    1. Hi, sorry i’m rewriting the comment, i hope you will receive this one as well.
      Did you use the very same ip address subnet on the tutorial? if yes, make sure the other machines are on the very same subnet (192.168.2.x) otherwise i guess the raspberry can access the internet because the wired connection is on a hardware level (mac address) and plus it has two external dns servers, so it could work even if your router was on 192.168.0.x instead of 192.168.2.x.

      Let me know

  2. Amigo, boa noite. Preciso de sua ajuda. Uso o rasp-pi com uma imagem que consta aplicativos para acesso ao sistema DSTAR.
    Agora comprei um LCD que veio com sua propria imagem. Funciona. Mas como faço para habilitar esse LCD-PI32 na imagem que tenho do DSTAR?

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.