Applies to: Ubuntu 26.04 and 24.04, Debian 13, AlmaLinux and Rocky Linux 9 and 10, RHEL 9 and 10; tested with netplan 1.2 on Ubuntu 26.04.1 and NetworkManager 1.56 on AlmaLinux 10.2 and 1.54 on AlmaLinux 9.8
There is no single network configuration file on Linux. Where the settings live depends on which tool manages the network, and that depends on the distribution:
- Ubuntu: netplan, in
/etc/netplan/*.yaml - Debian server without a desktop: ifupdown, in
/etc/network/interfaces(and/etc/network/interfaces.d/) - AlmaLinux, Rocky Linux, RHEL 9 and 10, Fedora: NetworkManager, in
/etc/NetworkManager/system-connections/*.nmconnection - systemd-networkd set up by hand:
/etc/systemd/network/*.network
Old guides that edit /etc/sysconfig/network-scripts/ifcfg-eth0 are out of date: see the RHEL section below.
Find out which one your server uses
ls /etc/netplan/ /etc/network/interfaces /etc/NetworkManager/system-connections/ /etc/systemd/network/ 2>/dev/null systemctl is-active NetworkManager systemd-networkd networking
The folder that contains files, and the service that shows active, is the one in charge. Get the interface name with ip -br addr. Always keep a console (VNC or IPMI) open when you change the network of a remote server: a mistake can cut off SSH.
Ubuntu: netplan
Netplan files are YAML, so indentation matters. Use spaces only: a tab gave Invalid YAML: tabs are not allowed for indent with the file name and line number. A static address looks like this (/etc/netplan/60-static.yaml):
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
addresses:
- 203.0.113.10/24
routes:
- to: default
via: 203.0.113.1
nameservers:
addresses: [1.1.1.1, 9.9.9.9]
Netplan doesn’t configure the network itself. sudo netplan generate writes files for the real backend, which you should never edit because they are rebuilt every time. For the file above it created /run/systemd/network/10-netplan-eth0.network:
[Match] Name=eth0 [Network] LinkLocalAddressing=ipv6 Address=203.0.113.10/24 DNS=1.1.1.1 DNS=9.9.9.9 [Route] Destination=0.0.0.0/0 Gateway=203.0.113.1
With renderer: NetworkManager it wrote /run/NetworkManager/system-connections/netplan-eth0.nmconnection instead. Apply changes with sudo netplan try (rolls back unless you confirm) or sudo netplan apply. Keep the files readable by root only (chmod 600); otherwise netplan warns Permissions for /etc/netplan/60-static.yaml are too open. Files are read in name order, and a server set up by cloud-init often has 50-cloud-init.yaml. Step by step: static IP on Ubuntu with netplan and additional IPv4 addresses with netplan.
Debian: /etc/network/interfaces
auto eth0
iface eth0 inet static
address 203.0.113.10/24
gateway 203.0.113.1
Check it with ifquery eth0 and apply it with sudo ifdown eth0 && sudo ifup eth0 from the console. If the file contains source /etc/network/interfaces.d/*, look in that folder as well. Debian with a desktop uses NetworkManager instead.
AlmaLinux, Rocky Linux and RHEL: NetworkManager keyfiles
Each connection is one INI-style file in /etc/NetworkManager/system-connections/. Red Hat advises against editing these files by hand; create and change them with nmcli, which checks the values. For example:
sudo nmcli connection modify eth0 ipv4.method manual ipv4.addresses 203.0.113.10/24 ipv4.gateway 203.0.113.1 ipv4.dns "1.1.1.1,9.9.9.9" sudo nmcli connection up eth0
A profile looks like this (created with nmcli --offline in our test, shortened):
[connection] id=eth0 type=ethernet interface-name=eth0 [ipv4] address1=203.0.113.10/24 dns=1.1.1.1;9.9.9.9; gateway=203.0.113.1 method=manual
ifcfg files: on AlmaLinux 9 the file /etc/sysconfig/network-scripts/readme-ifcfg-rh.txt says the ifcfg format is deprecated, new profiles are stored as keyfiles, and old ones can be converted with nmcli connection migrate. According to Red Hat, RHEL 10 removed support for ifcfg files completely, and on our AlmaLinux 10 system the network-scripts folder doesn’t exist. Convert any ifcfg profiles on version 9 before you upgrade. More examples: additional IPv4 addresses with nmcli.
Other files that belong to the network setup
/etc/hostname: the server’s name. Change it withsudo hostnamectl set-hostname server1.example.com./etc/hosts: fixed name-to-address entries. With the usualhosts: files dnsline in/etc/nsswitch.conf(as on Ubuntu 26.04), they are checked before DNS./etc/resolv.conf: the DNS servers the system uses. On Ubuntu with systemd-resolved it is a link to/run/systemd/resolve/stub-resolv.conf, and NetworkManager can also write it. Set DNS servers in the netplan or NetworkManager configuration, not in this file, or your change is overwritten.
To check the result, use ip -br addr, ip route and a ping to the gateway. The older ifconfig and route commands (net-tools) are often not installed on current releases: see ifconfig compared with ip.
Official documentation: netplan, interfaces(5) and Red Hat: NetworkManager keyfiles.