Linux · Raspberry Pi · Uncategorized

Changing IP address of your Raspberry Pi from Dynamic to a Static ip address

If your Raspberry Pi is configured to used a dynamic ip address and you would like to assign it a static address so that u can use it as a home server, use the following steps.

First of all, you need to identify the Raspberry Pis existing IP address. If you have access to the console, it is easy to do, if not you shall require to run some kind of network scan or check the DHCP lease for identifying the address. Follow this link for identifying the ip address of Raspberry Pi using network scan.

You shall need to identify your devices

  • IP address
  • Netmask/Network address
  • Default gateway
  • DNS

If you have console access you can examine the IP address  using the following command ( this shall work both over ssh using putty and directly from the console)

ip addr

The output will be something similar to this, follow the bold section

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:25:43:23 brd ff:ff:ff:ff:ff:ff
inet brd scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::88a5:bc2e:fd52:87fd/64 scope link
valid_lft forever preferred_lft forever

This indicates the ip address of the RaspberryPi device is

The netmask is /24 or

Which makes the network address of

To find out the default gateway run

route -n

You shall see a similer output of

pi@raspberrypi ~ $ route -n
Kernel IP routing table
Destination         Gateway         Genmask          Flags      Metric Ref     Use       Iface                   UG         202     0        0            eth0     U           202     0        0            eth0

Default gateway

To find out the dns addrss assigned by the dhcp server

cat /etc/resolv.conf

pi@raspberrypi ~ $ cat /etc/resolv.conf
# Generated by resolvconf

DNS server/Name server is

Now that we have the information we need to change the Raspberry Pi configuration from dynamic to static we can start changing the configuration. Before we make any changes, it is wise to make a backup of the file you intend to change

sudo cp /etc/network/interfaces /etc/network/interfaces.orig

Now edit the file

 sudo nano /etc/network/interfaces

You shall see something like this


Remove the line that reads

iface eth0 inet manual

Add the following

allow-hotplug eth0
iface eth0 inet static

Now to check run

sudo service networking restart

Your device ip address is static.


route -n
cat /etc/resolve.conf

Try pinging other hosts check connectivity. Hope you find this tutorial useful.

One thought on “Changing IP address of your Raspberry Pi from Dynamic to a Static ip address

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s