Debian servers usually configure the network with ifupdown and the file /etc/network/interfaces. Ubuntu uses Netplan instead, and desktops often use NetworkManager, which is why guides on the internet disagree. This guide covers a standard Debian server (Debian 12 “Bookworm” or 13 “Trixie”).

Working on a remote VPS? A mistake in network settings can lock you out of SSH. Before changing anything, make sure you can reach the server’s VNC console from your control panel, and keep a copy of the original file.

1. See what you have

ip -br addr        # interfaces and their IP addresses
ip route           # routes, including the default gateway
cat /etc/resolv.conf   # DNS servers

Example output:

lo      UNKNOWN  127.0.0.1/8 ::1/128
ens3    UP       203.0.113.20/24

Modern interface names look like ens3, enp1s0 or eth0 — use whatever ip shows.

2. The interfaces file

cat /etc/network/interfaces

A server with DHCP:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet dhcp

A server with a static IP:

auto lo
iface lo inet loopback

auto ens3
iface ens3 inet static
    address 203.0.113.20/24
    gateway 203.0.113.1
    dns-nameservers 1.1.1.1 8.8.8.8

The dns-nameservers line only takes effect if the resolvconf package is installed; otherwise set DNS in /etc/resolv.conf (below). Use the IP, prefix and gateway from your provider — on a VPS they’re in the welcome email or control panel.

3. Apply changes safely

cp /etc/network/interfaces /root/interfaces.bak
nano /etc/network/interfaces
systemctl restart networking

Restarting networking over SSH may drop your session for a moment. If the configuration is wrong you’ll lose access — that’s what the VNC console is for. A safer trick is to schedule an automatic rollback first:

(sleep 120 && cp /root/interfaces.bak /etc/network/interfaces && systemctl restart networking) &
systemctl restart networking
# If you can still connect, cancel the rollback:
kill %1

4. DNS

Without resolvconf, edit the resolver file directly:

# /etc/resolv.conf
nameserver 1.1.1.1
nameserver 8.8.8.8

Test it:

getent hosts debian.org

If the file is overwritten after reboot, a DHCP client or cloud-init is managing it — set DNS there instead.

5. Add an extra IP address

If your VPS has additional IPs, add them to the same interface:

auto ens3
iface ens3 inet static
    address 203.0.113.20/24
    gateway 203.0.113.1

iface ens3 inet static
    address 203.0.113.21/24

Or temporarily, until reboot: ip addr add 203.0.113.21/24 dev ens3. Check your provider’s instructions — some assign extra IPs with a /32 prefix or a different gateway. Plans with many IPs are covered on our Multi-IP VPS page.

6. Hostname and /etc/hosts

hostnamectl set-hostname web1.example.com

Then make sure /etc/hosts has a matching line:

127.0.1.1   web1.example.com web1

7. Troubleshooting checklist

Symptom Check
No IP on the interface systemctl status networking, journalctl -u networking; wrong interface name in the file?
IP works but no internet ip route — is there a default via line? Can you ping the gateway?
Can ping 1.1.1.1 but not debian.org DNS problem — check /etc/resolv.conf
Some ports unreachable from outside Firewall: nft list ruleset or ufw status
Slow or lossy connection mtr -rw example.com to see where packets are lost

Next steps

All our Debian VPS plans come with a VNC console in the control panel, so you can fix network mistakes even when SSH is down.

  • Debian
  • Networking
  • Linux