Static IP

[Last updated: 02/12/2019]

In this tutorial I will show you how to set a static IP address on your Pi with Raspbian.

At the time of writing this article, the latest release date of Raspbian Stretch is 11-13-2018 with Kernel version 4.14.

I will do this operation on a fresh install of Raspbian.

Connect to your Raspberry Pi via SSH, or use a keyboard (and screen) directly connected on the Raspberry Pi.

Open a terminal window.

Type the following command : sudo nano /etc/dhcpcd.conf

With the keyboard down arrow go down all the way to the end of this file and add one, or both of the following code blocks. Depending on whether you want to set a static IP address for a wired connection (eth0 = wired) or a wireless connection (wlan0 = wireless).

You’ll need to edit the numbers in the snippet so they match your network configuration.

interface eth0
static ip_address=192.168.1.10/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

interface wlan0
static ip_address=192.168.1.200/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

interface : This defines which network interface you are setting the configuration for;
static ip_address = This is the IP address that you want to set your device to. (Make sure you leave the /24 at the end);
static routers = This is the IP address of your gateway (the IP address or your router);
static domain_name_servers = This is the IP address of your DNS (probably the IP address of your router). You can add multiple IP addresses here separated with a single space.

To Save, type ctrl+o then ENTER

To exit the editor, press ctrl+x

Now you need to reboot, and everything should be set.

Type the command sudo reboot now

To verify that the configuration has been completed, type the command : ifconfig

Voilà.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.