Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Debian Linux IP Address Configuration: A Practical Guide

To configure an IP address on Debian, first identify which network manager controls the interface: a desktop commonly uses NetworkManager, while some servers use ifupdown or systemd-networkd. Set the address in that manager’s configuration for a lasting change; commands such as ip addr are useful for checking or making temporary changes, but do not normally survive a reboot.

How Debian manages network addresses

Debian does not have one universal file for network settings. The active configuration method depends on how the system was installed and what software is running. NetworkManager is common on desktop installations and provides both a graphical control panel and the nmcli command. The traditional ifupdown package reads settings from /etc/network/interfaces and remains common on some servers. Other installations may use systemd-networkd, which reads files under /etc/systemd/network/.

These tools can configure the same kinds of things—addresses, routes, and DNS—but their configuration files are not interchangeable. Avoid having two managers configure the same interface: competing settings can cause an address to disappear, routes to change unexpectedly, or the connection to flap. Before editing anything, check the current state and the tools installed:

  • ip -br addr lists interfaces and their addresses in a compact format.
  • ip route shows IPv4 routes, including the default route when one exists.
  • systemctl is-active NetworkManager systemd-networkd can help identify active services; a result alone does not prove which service manages a particular interface.
  • cat /etc/network/interfaces shows the traditional ifupdown configuration, if that file exists.

On a desktop, the NetworkManager applet or nmcli device status can show which connection profile is associated with an interface. On a server, inspect the installed network packages and existing configuration before choosing a method. Do not add a second configuration just because the first file you look at appears empty.

Identify the interface and current settings

Interface names are not necessarily eth0 or wlan0. Debian systems often use predictable names such as enp1s0 for Ethernet or wlp2s0 for wireless, though the exact name varies with hardware and system configuration. Get the real name from ip -br link or ip -br addr, then use that name consistently in commands and configuration.

An address is only one part of working network access. A typical IPv4 setup also needs a subnet prefix, a default gateway for destinations outside the local subnet, and working DNS servers to resolve names such as debian.org. For example, 192.168.1.50/24 describes an address and a 24-bit network prefix; it does not, by itself, tell Debian which router or DNS server to use. Check the router or network administrator for the correct values rather than copying example addresses into a real network.

Configure a static address with ifupdown

If the system uses ifupdown, edit /etc/network/interfaces as root. A simple Ethernet configuration with a manually assigned IPv4 address looks like this:

auto enp1s0
iface enp1s0 inet static
    address 192.168.1.50/24
    gateway 192.168.1.1

Replace the interface name, address, prefix, and gateway with values appropriate for the network. The auto directive asks ifupdown to bring the interface up during system startup. Another commonly used directive is allow-hotplug, which brings an interface up when the system detects it; the choice depends on the device and the desired startup behavior.

DNS settings are often supplied by DHCP or managed separately from the interface address. If the machine uses a resolver manager, configure DNS through that manager rather than assuming an interfaces entry will be applied. Some ifupdown setups support DNS options through additional packages such as resolvconf; availability and behavior depend on what is installed. Inspect /etc/resolv.conf and the resolver service before changing DNS files by hand, because the file may be generated or linked to managed data.

After changing an ifupdown configuration, apply it using the appropriate network service or by bringing the interface down and up with ifdown and ifup. These operations can interrupt a remote session. On a local machine, a reboot is one way to test that the configuration is applied at startup, but it is not a substitute for checking the result with ip addr and ip route.

Use DHCP when the network assigns addresses

For a network that provides addresses automatically, an ifupdown stanza can use DHCP instead of a fixed address:

auto enp1s0
iface enp1s0 inet dhcp

DHCP can provide the interface address, subnet information, default route, and DNS servers. This is usually the simplest choice for a laptop, a home network, or a system whose network administrator expects clients to use automatic addressing. With NetworkManager, a connection profile set to automatic IPv4 configuration typically uses DHCP on ordinary Ethernet networks.

Automatic addressing does not mean a device must always receive the same address. A DHCP server may renew the same lease for a while, but its behavior depends on the server and network. If a server or printer needs a predictable address, ask the network administrator whether to create a DHCP reservation tied to the device’s network identity. A reservation often avoids conflicts more safely than choosing an unused-looking address and configuring it manually.

Set an address with NetworkManager

For a NetworkManager-managed connection, use its profile rather than editing /etc/network/interfaces for the same interface. Start with nmcli connection show to find the profile name and nmcli device status to see device associations. A static IPv4 profile can be set with commands like these, replacing the example profile and network values:

nmcli connection modify Wired\ connection\ 1 \
    ipv4.method manual \
    ipv4.addresses 192.168.1.50/24 \
    ipv4.gateway 192.168.1.1 \
    ipv4.dns 192.168.1.1
nmcli connection up Wired\ connection\ 1

Connection names containing spaces need shell quoting or escaping; for example, the profile can instead be written as 'Wired connection 1'. The command sets the profile to manual IPv4 configuration, assigns an address and gateway, and specifies a DNS server. The example DNS server is only suitable if that address actually provides DNS on the local network. You can also change these settings in the desktop network panel by selecting the connection, opening its IPv4 settings, choosing manual configuration, and saving the values.

For automatic IPv4 addressing, set ipv4.method auto on the profile and bring it up. NetworkManager profile settings persist, unlike a one-off address added with the ip command. If a connection has both IPv4 and IPv6 settings, configure each family deliberately; setting IPv4 to manual does not necessarily disable IPv6.

Temporary changes and IPv6

The ip command is useful for diagnosis or a short-lived test. For example, sudo ip address add 192.168.1.50/24 dev enp1s0 adds an address until it is removed or the system is reconfigured. To add a default route temporarily, use sudo ip route add default via 192.168.1.1. These commands do not update NetworkManager, ifupdown, or systemd-networkd configuration. A manager may replace the settings, and a reboot will normally remove manually added runtime changes.

IPv6 is configured separately from IPv4. A network may use router advertisements for automatic addressing, DHCPv6, or a manually assigned address and route. With ifupdown, IPv6 uses an inet6 stanza; with NetworkManager, use the profile’s IPv6 settings. Do not copy an IPv4 gateway or prefix into IPv6 fields. Addresses beginning with 2001:db8:: are reserved for documentation examples and are not real public addresses to use on the internet.

Common problems and safe troubleshooting

  • Wrong interface name: Confirm the name with ip link. A configuration referencing a nonexistent interface will not configure the intended device.
  • Address conflict: Two devices using the same static address can disrupt both. Confirm that the address is reserved or excluded from the DHCP pool before assigning it.
  • Missing default route: A host may communicate with nearby devices yet fail to reach other networks. Check ip route and verify the gateway is correct and reachable on the local subnet.
  • DNS failure: If an IP address works but hostnames do not, investigate DNS rather than repeatedly changing the interface address. Check the resolver configuration and test the configured DNS service.
  • Changes do not take effect: Check which manager owns the interface, whether the profile is active, and whether the configuration has a syntax error. Restarting the wrong service will not fix settings owned by another manager.
  • Remote lockout: Changing an address, route, or firewall rule over SSH can sever the session. Keep console or out-of-band access available, and make a rollback plan before applying a risky change.

A useful diagnostic sequence is to check the link, address, route, and name resolution separately. ip link shows whether the interface is administratively up; ip addr shows assigned addresses; ip route get 1.1.1.1 reports the route the kernel would use to reach that IPv4 destination. A successful route lookup does not prove the destination or DNS is reachable, but it can reveal a missing or unexpected route. Then test a known reachable local host and check DNS using the tools available on the system.

Frequently Asked Questions

How do I find my Debian IP address?
Run ip -br addr in a terminal. Look for the relevant Ethernet or wireless interface and an address listed beside it. The command may show both IPv4 and IPv6 addresses; loopback addresses belong to the local system and are not addresses for other machines to reach.

Where is the Debian IP configuration file?
There is no single file for every Debian installation. Ifupdown commonly uses /etc/network/interfaces, NetworkManager stores connection profiles and can be managed with its applet or nmcli, and systemd-networkd uses files under /etc/systemd/network/. Identify the active manager before editing.

How do I make a Debian IP address permanent?
Configure it in the network manager that owns the interface. Use a saved NetworkManager profile, an ifupdown stanza, or a systemd-networkd configuration as appropriate. An address added with ip address add is a runtime change and is not normally persistent after reboot.

Should I use DHCP or a static IP?
Use DHCP when the network is intended to assign settings automatically. If an address must remain predictable, a DHCP reservation is often the easiest option when you control the router or DHCP server. Use a manually configured static address when the network administrator provides a suitable address and confirms it will not conflict.

Why can I reach an IP address but not a website name?
This commonly points to a DNS problem, not necessarily an IP-address problem. Check which DNS server the active manager supplied, whether that server is reachable, and whether a resolver service is managing /etc/resolv.conf. Also verify that the failure is not caused by a proxy, firewall, or unavailable website.

Will restarting networking disconnect SSH?
It can. Bringing down an interface or changing its address, route, or connection profile may end the remote session immediately. Apply such changes from a local console when possible, or arrange alternate access and a recovery plan before proceeding.

Debian Linux IP Address Configuration: A Practical Guide
Scroll to top