Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Linux Network Configuration File on Ubuntu

· 5 min read · Home Networking

In this article
  1. Where Ubuntu Keeps Network Settings
  2. How Netplan Works
  3. Example: A Static IPv4 Address
  4. Editing and Applying Changes Safely
  5. Netplan Compared With Interfaces and NetworkManager
  6. Common Problems and Checks
  7. Frequently Asked Questions

On Ubuntu, the main network configuration file depends on the release and networking service in use. On most current Ubuntu Server installations, network settings are declared in YAML files under /etc/netplan/; desktop editions commonly use NetworkManager, which Netplan may configure behind the scenes. Older releases may instead use /etc/network/interfaces, so check the system before editing.

Where Ubuntu Keeps Network Settings

Start by identifying the configuration files that exist:

  • /etc/netplan/*.yaml — the usual configuration location on Ubuntu 18.04 and later installations that use Netplan.
  • /etc/network/interfaces — the traditional ifupdown configuration file, found on older Ubuntu systems or systems explicitly configured to use that service.
  • NetworkManager connection profiles — commonly managed through the desktop settings, nmcli, or files in /etc/NetworkManager/system-connections/.

These mechanisms are not interchangeable. A machine can have more than one of these files, but that does not mean each file controls the active connection. First find which service is managing the network interface; changing an inactive configuration file will have no effect.

How Netplan Works

Netplan is a configuration layer that reads YAML files from /etc/netplan/ and generates settings for a backend. Ubuntu Server commonly uses systemd-networkd, while Ubuntu Desktop commonly uses NetworkManager. The backend may vary by installation, and Netplan files can be merged, so inspect the directory rather than assuming a particular filename such as 01-netcfg.yaml.

To see the files and rendered configuration, use:

  • ls -l /etc/netplan/ to list the YAML files.
  • sudo netplan get to display the current Netplan configuration, where supported by the installed version.
  • networkctl or nmcli device status to help identify which network service is active.

Netplan is declarative: the YAML describes the desired network setup, and netplan apply passes the generated configuration to the selected backend. It is not normally necessary to edit the backend’s generated files directly; make the change in Netplan’s source configuration instead.

Example: A Static IPv4 Address

A basic Netplan configuration for an Ethernet interface might look like this. Replace the interface name and example addresses with values that match the network:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s0:
      dhcp4: false
      addresses:
        - 192.168.1.50/24
      routes:
        - to: default
          via: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1, 1.1.1.1]

Here, enp3s0 is the interface name, /24 is the network prefix, the route sets the default gateway, and the nameserver list supplies DNS servers. Do not copy these example addresses blindly: an address already in use, an incorrect prefix, or a gateway outside the local subnet can make the host unreachable. If the machine should receive its address automatically, use dhcp4: true instead of the static address, route, and DNS settings as appropriate.

Editing and Applying Changes Safely

Before editing, make a backup and confirm the interface name with ip link. YAML indentation matters: use spaces, not tabs, and keep child settings indented consistently. A syntax error can prevent the configuration from being applied.

  1. Back up the file you plan to change, for example with sudo cp /etc/netplan/example.yaml /etc/netplan/example.yaml.bak, replacing the filename with the actual one.
  2. Edit the YAML file with a text editor and check the indentation and values.
  3. Run sudo netplan generate to check and generate the backend configuration.
  4. For a remote system, prefer sudo netplan try when available. It offers a temporary test and can revert if you do not confirm, helping avoid a lockout.
  5. If the configuration is correct, apply it with sudo netplan apply, then verify the address, route, and DNS resolution.

A network change can disconnect an SSH session, especially if it changes the address, gateway, or interface. Keep console or out-of-band access available for important remote systems, and arrange a maintenance window when appropriate.

Netplan Compared With Interfaces and NetworkManager

The file /etc/network/interfaces belongs to the older ifupdown approach. A legacy setup might define an interface with auto, iface, and options such as address or gateway. That syntax is not valid Netplan YAML. Likewise, editing a NetworkManager profile is different from editing a Netplan file, even when NetworkManager is the backend that ultimately configures the interface.

On Ubuntu Desktop, the graphical network settings and nmcli are often the most direct tools for managing a NetworkManager connection. On a Netplan-managed system, use Netplan as the configuration source. Avoid maintaining conflicting settings for the same interface in multiple systems; competing managers can produce confusing or inconsistent results.

Common Problems and Checks

If a change appears to do nothing, first verify that you edited the file used by the active network manager. Then check the interface name, YAML indentation, and whether another Netplan file defines conflicting values. Commands such as ip address, ip route, resolvectl status, and journalctl -u systemd-networkd can help distinguish address, routing, DNS, and service problems. For NetworkManager, inspect status with nmcli.

Do not assume that restarting a service is always required; Netplan’s normal application command is sudo netplan apply. Also, a working IP connection does not prove DNS is configured correctly: test an IP address and a hostname separately. If remote access is lost, use local console access to restore the backup or correct the configuration.

Frequently Asked Questions

What is the network configuration file in Ubuntu?
For most current Ubuntu Server systems, it is one or more YAML files in /etc/netplan/. The exact file depends on the installation. Older or specially configured systems may use /etc/network/interfaces or NetworkManager profiles.

How do I find my Ubuntu network configuration file?
Run ls -l /etc/netplan/ and inspect the files. Then check the active manager with commands such as networkctl or nmcli device status. The presence of a file alone does not prove that it controls the interface.

How do I change my IP address in Ubuntu?
On a Netplan-managed system, edit the relevant YAML file under /etc/netplan/, set DHCP or a static address and related route and DNS values, validate it, and apply it. On a desktop managed directly by NetworkManager, use the network settings or nmcli.

Does Ubuntu still use /etc/network/interfaces?
Some older installations and systems using ifupdown do. It is not the default configuration file for most current Ubuntu installations that use Netplan, and editing it may not affect a Netplan-managed connection.

How do I apply Netplan changes?
Use sudo netplan generate to check and generate the configuration, then sudo netplan apply. For remote changes, sudo netplan try is safer when supported because it provides an opportunity to revert an unconfirmed change.