How to Set Up a Static IP on Linux
From NetworkManager or netplan, so your machine always has the same address on your network.
A static IP makes sure your machine always has the same address on your network — useful for home servers, network printers, or any device you need to connect to consistently.
With NetworkManager (most desktops)
- Network Settings → select your connection → settings icon.
- IPv4 tab → switch from "Automatic (DHCP)" to "Manual".
- Add the IP address you want, the network mask (usually
255.255.255.0), and the gateway (your router's IP).
Tip: choose an IP outside the range your router hands out automatically (check the router's settings) — that way you avoid two devices ending up with the same address by mistake.
From the terminal (netplan, on Ubuntu-based distributions)
sudo nano /etc/netplan/01-netcfg.yaml
Edit the configuration with your fixed IP, save, and apply:
sudo netplan apply
Frequently asked questions
Why do I need a static IP?
It's useful when you need to consistently connect to a specific device (a home server, a network printer) without its address changing every time it restarts.
Can I choose any IP address?
No, it must be within your local network's range and, preferably, outside the range your router assigns automatically via DHCP, to avoid conflicts with other devices.