How to set static IP address in Raspbian?

Mariusz Wyszomierski Raspberry Pi How to set static IP address in Raspbian?

Raspberry Pi

How to set static IP address in Raspbian?

Posted By Mariusz Wyszomierski

Option 1 – set static IP address in router

Many routers have settings to assign static IP address based on MAC addres of network card.
Each router has different administration panel, so I won’t describe this option in detail.
If IP address of your local network is you probably can access in browser “” to administration panel of router.

When you choose option 2 or 3 you should configure DHCP server to assign dynamic IP only from selected range.
In my router settings looks like:


Now DHCP server will assign newly connected devices IP address from range –
Therefore you can set static IP in range (ending “1” is router address) to

Option 2 – edit file /etc/network/interfaces

1) Login to Raspbian

2) Make backup of network settings

sudo cp /etc/network/interfaces /etc/network/interfaces.bak

3) Edit file

sudo nano /etc/network/interfaces

4) Put settings in file

  • address – static IP addres
  • netmask – local network mask
  • gateway – local network gateway
auto lo
iface lo inet loopback

iface eth0 inet static

4) Save changes

CTRL+x, Y [yes]

5) Delete cache DHCP

sudo rm /var/lib/dhcp/*
sudo rm /var/lib/dhcpcd5/*

6) Restart system

sudo reboot

Option 3 – dhcpcd.conf

When there is comment in file /etc/network/interfaces (for example Raspbian 1.5):

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

you should change file “/etc/dhcpcd.conf”:

interface eth0
static ip_address=
static routers=
static domain_name_servers=
  • ip_address – static IP address
  • domain_name_servers – IP addresses of DNS (in this example it’s google DNS).

Tagged , , ,

Written by Mariusz Wyszomierski

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.