How to set static IP address in Raspbian?

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
1sudo cp /etc/network/interfaces /etc/network/interfaces.bak
  1. Edit file
1sudo nano /etc/network/interfaces
  1. Put settings in file
  • address - static IP addres
  • netmask - local network mask
  • gateway - local network gateway
1auto lo
2iface lo inet loopback
4iface eth0 inet static
  1. Save changes CTRL+X and then Y [yes]
  2. Delete cache DHCP
1sudo rm /var/lib/dhcp/*
2sudo rm /var/lib/dhcpcd5/*
  1. Restart system
1sudo 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:

1interface eth0
2static ip_address=
3static routers=
4static domain_name_servers=
  • ip_address - static IP address
  • domain_name_servers - IP addresses of DNS (in this example it's google DNS).