Give a fixed IP to your Raspberry

You have been many (OK only 2 !) wondering how to set a static IP as Raspbien. So today we'll see together the method which is very simple.

Donner une IP statique à votre Raspberry

The network under Rasbian configuration happens in a file : /etc/network/interfaces. By default, Here's what you should have (It also allows you to have default values) :

Auto lo
iface lo inet loopback iface eth0 inet dhcp
allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp

Then, in detail, This file contains the following information :

  • Auto lo : will start the interface automatically during the boot sequence
  • iface lo inet loopback : definition of the loopback interface (you know what essential)
  • iface eth0 inet dhcp : interface eth0 (the RJ45 of the Raspberry) will be configured by sending a DHCP request over the network. Dynamic IP so ..
  • The next block to configure hot wifi via the wpa_supplicant configuration file. In DHCP.

Now to set up a static IP, the principle is simple :

  • Remove the eth0 and wlan0 block you want to change
  • The configuration of the interface : IP, mask and gateway.
  • Restart the machine

For example, your local network behind your router is 192.168.1.x . The address of your router is Therefore, the mask of your network (more info on the netmask on Wikipedia here). And you want your address to be

Here's what you'll put in your file /etc/network/interfaces for example the ethernet interface :

iface eth0 inet static address



Now the contents of your complete file :

Auto lo iface lo inet loopback
iface eth0 inet static address


allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp

You can now restart the Raspberry and your IP will be the one that you configured. Alternatively, you can restart only the interface :

ifdown eth0 ifup eth0

If you have a DNS problem (google ping does not for example) You can add this line to the block of the interface, After the line gateway :


Now for me I'm not a fan of static IP. All my machines are on DHCP. I locked the DHCP range and I use leases based on my MAC addresses. Clearly it will not guarantee an intrusion on the network (change its MAC address is possible) but this is useful for devices that travel.

Some time ago, on holiday in the Sun (Yeah the yellow thing in the sky which gives heat, Remember) no way in the hotel to have Internet. The problem was with my fixed IP forced on the comp, I didn't have the right to use the wifi. At the time I had been obliged to return to DHCP. That is why now I prefer to stay in DHCP do not have to redo the config from / the notebook(s) et tablette 😉

So you have an opportunity to do not modify your configuration and to always have the same IP you.

You can play now for your configuration.

You may also like...