Skip to content
  • English Deutsch

benjamin-abt.com

Performance is a feature | Cloud - AI - Azure - .NET - Sustainability

  • Home
  • Blog
  • Portfolio
    • Overview
    • Workshops & Training
    • Publications
  • Contact
  • Home
  • Blog

Raspberry Pi OS: Set a Static IP Address

Raspberry Pi OS: Set a Static IP Address
August 15, 2025 3 min read BEN ABT
Raspberry

A static IP address ensures your Raspberry Pi is always reachable at the same network address instead of receiving a new one from the router each time it boots. This is particularly important when the Pi provides a service that other devices must reliably find, such as SSH access, a web server, Home Assistant, Pi‑hole, a Minecraft server or anything behind a port‑forward on your router.

When to use a static IP on the Pi vs. a DHCP reservation on the router:

  • Use a static IP on the Pi when you fully control the device and network segment or when your router can’t create DHCP reservations.
  • Prefer a DHCP reservation (a “static lease”) on the router if possible. The router will still hand out the address via DHCP but always assign the same one to the Pi’s MAC address. This avoids address conflicts and centralizes IP management.

If you configure the address on the Pi, choose one outside the DHCP pool of your router. Otherwise the router may hand the same address to another device.

Which method applies to your Raspberry Pi OS version?

Raspberry Pi OS changed its network stack with Bookworm (released in October 2023):

  • Bookworm and later use NetworkManager. /etc/dhcpcd.conf no longer exists there and editing it has no effect.
  • Bullseye and earlier use dhcpcd.

Check your version and the active network service:

Bash
1grep VERSION_CODENAME /etc/os-release
2systemctl is-active NetworkManager

If NetworkManager is active, follow the NetworkManager section. Otherwise use the dhcpcd section.

The examples use 192.168.1.100/24 as the Pi’s address and 192.168.1.1 as router and DNS server. Replace these values with the ones of your network.

Bookworm and later: NetworkManager

  1. List the connections and note the name of the one you want to change:
Bash
nmcli connection show

The wired connection is usually named Wired connection 1; a Wi-Fi connection is usually named after its SSID.

  1. Set the static address, gateway and DNS server:
Bash
sudo nmcli connection modify "Wired connection 1"   ipv4.method manual   ipv4.addresses 192.168.1.100/24   ipv4.gateway 192.168.1.1   ipv4.dns 192.168.1.1
  1. Reactivate the connection to apply the change:
Bash
sudo nmcli connection up "Wired connection 1"

If you are connected via SSH, the session drops when the address changes. Reconnect to the new address.

As an alternative to the command line, sudo nmtui offers a text-based UI for the same settings.

Bullseye and earlier: dhcpcd.conf

  1. Open the dhcpcd.conf file in a text editor:
Bash
sudo nano /etc/dhcpcd.conf
  1. Add the following lines at the end of the file, replacing eth0 with your network interface (use ip a to find your interface name; Wi-Fi is usually wlan0):
Config
1interface eth0
2static ip_address=192.168.1.100/24
3static routers=192.168.1.1
4static domain_name_servers=192.168.1.1
  1. Save the file and exit the text editor. Ctrl + X, then Y and Enter

  2. Restart the dhcpcd service:

Bash
sudo systemctl restart dhcpcd

As with NetworkManager, an SSH session drops when the address changes.

Verify the configuration

Check that the interface has the new address and that the router is reachable:

Bash
1ip a
2ping -c 3 192.168.1.1

Conclusion

A static IP address is particularly useful when you want to ensure that your Raspberry Pi is always reachable at the same address on the network. This is important for applications that require a constant network connection, such as servers, IoT devices or remote control. On current Raspberry Pi OS versions you configure it with NetworkManager, on older versions through dhcpcd.conf. The address stays the same across reboots; if the Pi moves to a different network, the static configuration has to be adjusted or removed.

Related articles

Raspberry Pi WS2812B Lightstrip Unit Testing Strategies with .NET

Aug 14, 2025 - 7 min read

Raspberry Pi WS2812B Lightstrip Unit Testing Strategies with .NET

Testing hardware-driven projects pays off quickly. Compared to driving a single LEGO motor, controlling a WS2812B lightstrip involves timing …

Raspberry Pi WS2812B Lightstrip Control with .NET

Aug 5, 2025 - 7 min read

Raspberry Pi WS2812B Lightstrip Control with .NET

In this beginner-friendly guide, you’ll learn how to control a WS2812B (aka “NeoPixel”) LED light strip with a Raspberry …

Raspberry Build HAT: Unit Testing Strategies with .NET

Jul 30, 2025 - 6 min read

Raspberry Build HAT: Unit Testing Strategies with .NET

If you go beyond hobby tinkering and aim for reliable, maintainable software, you need tests. Hardware projects are no exception. In fact, …


BEN ABT

BEN ABT

Ben is Chief Engineering Officer and Principal Software Engineer at Medialesson.de, with a strong focus on .NET and Microsoft Azure. In his professional role, he designs and builds highly scalable platforms for hybrid and cloud-based scenarios. He also advises companies and C-levels on migrating to the sovereign cloud.

He runs myCSharp.de, the largest and most active German-speaking C# community forum, actively contributes to both his own and external open-source projects and regularly shares his knowledge through his blog, at community events, conferences and as a writer for technical magazines.

Let's Work Together

Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

New Platforms

Modernization

Training & Consulting

Contact Me
X Facebook LinkedIn WhatsApp
Back Next Blog Post

Open for work!

Contact Me
BEN ABT BEN ABT Software Engineer · Microsoft MVP Passionate about .NET, Azure, performance optimization and sustainable software engineering.

Medialesson GmbH Logo

Microsoft MVP Logo

Recent posts

View all
Stop Using nginx as Your Default Static File Server in Docker

Stop Using nginx as Your Default Static File Server in …

Oct 24, 2026
Containerizing .NET in 2026 Without a Dockerfile

Containerizing .NET in 2026 Without a Dockerfile

Oct 20, 2026
Problem Details in ASP.NET Core and .NET 11

Problem Details in ASP.NET Core and .NET 11

Oct 5, 2026
Resilience in .NET with Microsoft.Extensions.Resilience

Resilience in .NET with Microsoft.Extensions.Resilience

Sep 21, 2026
What Matters in ASP.NET Core 11

What Matters in ASP.NET Core 11

Sep 14, 2026

Tags

.NET (192) Csharp (96) ASP.NET Core (48) Azure (41) DevOps (17) Docker (14) Microsoft (14) EF Core (11) Microsoft MVP (11) AI (10) GitHub (10) GitHub Copilot (10) ASP.NET (9) Security (9) Synology (9) Architecture (8) Raspberry (8) Azure Functions (7) Cloudflare (7) Bicep (6)
benjamin-abt.com

About BEN

Benjamin Abt is a Software Engineer, Platform Architect and Microsoft MVP specializing in .NET, Azure, cloud architecture, performance optimization and sustainable software development.

Connect

  • Follow me on GitHub
  • Follow me on LinkedIn
  • Follow me on Mastodon
  • Microsoft MVP profile
  • Follow SchwabenCode on GitHub
  • Follow me on X

Quick Links

  • Portfolio
  • Blog
  • Workshops & Training
  • Publications
  • Get in Touch
  • Sitemap
Open for Work

© Copyright Benjamin Abt & SchwabenCode | 2011 - 2026

Content licensed under CC BY 4.0 unless otherwise noted.

  • Impressum
  • Privacy
  • Contact