A server whose address changes every reboot is a server you cannot rely on. Setting a Debian 12 static IP gives your machine a permanent address for SSH access, DNS records, firewall rules, and monitoring. Debian does not use netplan by default like Ubuntu does — a traditional Debian installation configures networking through ifupdown and the /etc/network/interfaces file, and knowing how that file works puts you in full control.
In this guide you will configure a static IP address on Debian 12 using ifupdown, set the gateway and DNS resolvers correctly, apply the changes without locking yourself out, and verify the result. We also cover the cases where NetworkManager or systemd-networkd is in charge instead, so you can identify which system your installation uses before editing the wrong file.
First: Identify Your Network Configuration System – How to Configure a Static IP
Debian 12 supports several network managers, and editing the wrong one wastes time:
- ifupdown – the default on server and netinst installations; configured in
/etc/network/interfaces. This guide focuses on it. - NetworkManager – default on most desktop installs (GNOME); use
nmcliornmtui. - systemd-networkd – common on cloud images and containers; configured in
/etc/systemd/network/.
Check which services are active:
systemctl is-active networking NetworkManager systemd-networkd
ip -br address
Note your interface name (for example ens18, eth0, or enp3s0) and the current DHCP-assigned address from the output — you will need them below. The Debian Wiki network configuration page documents all three systems if yours differs.

Gather the Values You Need – How to Configure a Static IP
Before editing anything, write down:
- The static IP you want to assign, e.g.
192.168.1.50— make sure it is outside your router’s DHCP pool to avoid address conflicts. - The subnet mask or prefix, e.g.
255.255.255.0(/24). - The gateway, usually the router:
192.168.1.1. - DNS servers, e.g.
1.1.1.1and8.8.8.8, or your internal resolver.
Warning for remote servers: changing the IP of a machine you are connected to over SSH will cut your session when the new settings apply, and a typo leaves the box unreachable. On a VPS, keep the provider’s web console open as a fallback before proceeding.
Step 1: Back Up the Current Configuration
sudo cp /etc/network/interfaces /etc/network/interfaces.bak
Do not skip this. A single bad line can prevent the interface from coming up at boot; the backup is your way back.
Step 2: Configure the Debian 12 Static IP in /etc/network/interfaces
Open the file in an editor:
sudo nano /etc/network/interfaces
Find the block for your interface — a DHCP setup usually reads:
allow-hotplug ens18
iface ens18 inet dhcp
Replace it with a static definition:
auto ens18
iface ens18 inet static
address 192.168.1.50/24
gateway 192.168.1.1
dns-nameservers 1.1.1.1 8.8.8.8
Notes on this block: auto brings the interface up at boot (you may see allow-hotplug instead on some installs — either is fine). The address line accepts CIDR notation (/24); older guides write separate netmask 255.255.255.0 lines, which also works. The dns-nameservers option requires the resolvconf package or systemd-resolved integration on classic ifupdown setups — if it is ignored on your system, manage DNS directly in /etc/resolv.conf as shown in Step 4.
Step 3: Apply the New Configuration
Restart the networking service to apply the static IP:
sudo systemctl restart networking
Or bounce just the interface:
sudo ifdown ens18 && sudo ifup ens18
If you are connected by SSH to the old address, reconnect now to the new static address. Verify the address, route, and connectivity:
ip -br address show ens18
ip route
ping -c 3 192.168.1.1
ping -c 3 deb.debian.org
A successful ping to the gateway proves the local network works; a successful ping to a hostname proves DNS works as well.
Step 4: Verify DNS Resolution
Check the effective resolvers:
cat /etc/resolv.conf
If your chosen DNS servers are missing, install the helper package and re-apply the interface:
sudo apt install -y resolvconf
sudo ifdown ens18 && sudo ifup ens18
On systems using systemd-resolved instead, resolvectl status shows the active DNS per interface.
The NetworkManager Case (Desktops)
If your Debian 12 machine runs a desktop with NetworkManager, /etc/network/interfaces is ignored for managed devices. Set the static IP with the terminal UI nmtui (Edit a connection → IPv4 → Manual), or with one command:
nmcli con mod "Wired connection 1" ipv4.method manual \
ipv4.addresses 192.168.1.50/24 ipv4.gateway 192.168.1.1 \
ipv4.dns "1.1.1.1 8.8.8.8"
nmcli con up "Wired connection 1"
Troubleshooting a Debian 12 Static IP Setup
The interface has no address after reboot
Look for syntax errors with sudo ifup -v ens18, which prints what ifupdown is doing. Confirm the stanza uses auto or allow-hotplug and the exact interface name from ip link — predictable names differ between machines.
“RTNETLINK answers: File exists” or duplicate address
Another device already uses your chosen IP, or the old DHCP address was never released. Pick an unused address outside the DHCP pool, and check arping -D 192.168.1.50 to detect conflicts.
Gateway unreachable
The address and gateway must be in the same subnet. A /24 address of 192.168.1.50 cannot use a gateway of 192.168.0.1. Double-check the prefix length you configured; this is also why our guide to editing the hosts file matters once the IP is fixed — name-based local access only works if the address stops changing.
Conclusion
Configuring a Debian 12 static IP with ifupdown takes one stanza in /etc/network/interfaces: address with prefix, gateway, and DNS. Back the file up first, keep a console handy on remote machines, and verify address, route, and DNS before declaring victory. With a permanent address in place, your server becomes a dependable target for SSH, DNS records, and monitoring.