Home Interests Raspberry Pi

How to Configure a Static IP Address on the Raspberry Pi

Making things a little less dynamic.
howchoo   (467)
September 15, 2023
8 minutes

Share

You'll Need 1

What you'll need
Interests
Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.
Posted in these interests:
pi • 92 guides

The network capabilities on the Raspberry Pi make it possible to create some really fun projects. Once in a while, you’ll come across a project that could benefit from a static IP address. If you’re using your Raspberry Pi for storage as a NAS device, an FTP server—or any other kind of server for that matter—a static IP address can be a big help.

1 – Update Raspberry Pi OS

This guide should work with any Raspberry Pi using Raspberry Pi OS (formerly Raspbian). Make sure your copy of is up to date. If you’re not sure where to begin, visit our guide on how to update Raspberry Pi OS.

How to Install Raspberry Pi OS on Your Raspberry Pi
Get the new official Raspberry Pi OS on your Pi.

2 – Find your router IP address

We’ll need both your router IP address and name server IP. We can find this information by running a few commands in a terminal on the Pi. Remote into the Pi using SSH or open a terminal window from within Raspberry Pi OS.

How to Connect to a Raspberry Pi Remotely via SSH
The preferred (and most common) method of connecting to your Pi to run commands.

To find your router IP address, enter the following command:

ip r | grep default

The router IP address will appear after the text “default via”—take note of it. The name server can be found in the resolv.conf file. Open it using the following command.

sudo nano /etc/resolv.conf

Take note of the name server IP address and close the file with CTRL + X.

3 – Edit the dhcpcd file on the Raspberry Pi

The static IP is set by adding it to a file on the Raspberry Pi. In the terminal window, run the following command to edit the dhcpcd.conf file.

sudo nano /etc/dhcpcd.conf

4 – Set the static IP address

This document has a few lines of code that can be activated by removing the # to the left of each line. Use the following ledger to properly set your static IP address.

  • Network = If you’re using a wired connection, set this to eth0. If you’re using a wireless connection, set this to wlan0.
  • Static_IP = This is the static IP address you want to assign to the Raspberry Pi.
  • Router_IP = This is the IP address for the router.
  • Name_Server = This is the name server address. You can use another DNS IP here if you’d like.

Enter your information into the file, be sure to remove the <> brackets. Check the screenshot for an example.

interface <Network>
static ip_address=<Static_IP>/24
static routers=<Router_IP>
static domain_name_servers=<Name_Server>

When that’s completed, save the file using CTRL + X.

5 – Test the static IP address

When the changes have been made, restart the Raspberry Pi. Now is a good time to test your project and make sure the IP address isn’t changing. Disconnect and reconnect your Pi from the network. If the IP address changes, verify the information in the previous step saved properly. If it stays the same, congratulations! You’ve set a static IP on the Raspberry Pi.

NEXT UP

How to Run a Minecraft Server on the Raspberry Pi

A whole world trapped inside your Pi.
howchoo   (467)
December 7, 2023

There are several ways to go about running a Minecraft server on the Raspberry Pi. In this guide, I’ll cover how to install Nukkit—a cross-platform Minecraft server that’s super easy to set up on the Raspberry Pi. This server should work with PCs, consoles, and tablets running Minecraft 1.14. I’ll be using a Raspberry Pi

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore