Fixed IP Setup Thumbnail

Fixed IP Address Over Ethernet & WiFi [Raspberry Pi]


If you intend on using a headless OS (such as Raspbian Lite) for your Pi, setting up a Fixed IP address is a must. With this setup, you can SSH into your Pi with nothing more than an Ethernet cable and a power supply connected to your Raspberry Pi.

Setting Up a Fixed IP

Before you can go about setting up a fixed IP address, you will first need to either connect to your Pi via SSH or connect a monitor, mouse and keyboard so that you can edit the configuration files.

Once you are ready at the terminal on your pi, open up the dhcpcd.conf file with nano by entering

> sudo nano /etc/dhcpcd.conf

Some posts around the internet talk about using an “interfaces file” for setting up a fixed IP. This used to be how Raspbian managed assignment of IP addresses, but has now moved over in favour of the dhcp client.

With the config file open in nano, scroll down to the bottom using your keyboards arrow keys to the end of the file. Enter the following:

interface eth0
 static ip_address=
 static routers=
 static domain_name_servers=
This looks like there is quite a lot involved, but broken down it is fairly straight forward.

interface eth0

Specifies which interface we want to assign the fixed ip address to. In this example we are assigning it to the ethernet port. If you have multiple ethernet wires plugged in (via a usb with ethernet adapter, for example) there will be more interface addresses such as eth1 etc. The same applies to WiFi, who’s interface range starts at wlan0.

 static ip_address=

The most important line of all! is the IP address you want to be assigned to your Pi.

What is the “/24” for? You may be wondering… This number represents the subnet mask, more specifically, how many bits of the mask should be 1 and the remainder being 0. As you may know, a common subnet mask is – as the subnet mask is a 32bit integer, this would be represented as /24 (i.e. the first 24 bits are 1’s and the remainder (8 bits) are 0).

static routers=

This one is fairly straight-forward. This is basically the IP address of the router you are connected to. Of course, change the IP address here to match your routers settings.

static domain_name_servers=

The final piece of the puzzle, and quite a simple one, is the dns settings. This is usually the same as your routers address, so change this accordingly.

Saving Settings

Finally, to save your settings:
  • ctrl + X to quit nano
  • Y to confirm to save
For the new settings to be applied, you will need to restart your Pi. Simply type the following:
> sudo reboot

Published by


Nick Cullen is a software developer living in South Wales, UK. He is primarily focused around coding in C++ and C# and loves tinkering with new programming languages and technologies. A key technological interest of his is Raspberry Pi development, which he has helped pioneer a unique product commercially using a Pi and programming the software in C++.

Leave a Reply

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