Configure IP Addresses and Network Interfaces on Linux
Configure static and dynamic IP addresses on Linux using ip, ifconfig, Netplan, and NetworkManager. View routes, interfaces, and network statistics.
Every Linux system that communicates over a network needs at least one network interface configured with an IP address, a subnet mask, and a default gateway. Linux gives you several layers of tooling to manage this: the modern ip command for live inspection and temporary changes, Netplan for persistent declarative configuration on Ubuntu, and NetworkManager for desktop or cloud environments. Understanding how these tools fit together helps you diagnose connectivity issues and apply changes that survive a reboot.
Before making any changes, inspect your current interface state to understand what the system already has configured.
ip addr show # list all interfacesip addr show eth0 # specific interfaceip link show # link layer infoifconfig # (legacy, may need net-tools)
Interface names vary by system. Older systems use eth0, while modern Linux kernels use predictable names such as ens3, enp3s0, or eno1. The name depends on your hardware slot, firmware, and udev rules. Run ip link show to see the exact names on your machine before referencing them in any configuration file.
The ip command applies changes immediately but they do not persist across reboots. Use these commands for testing or quick fixes.
sudo ip addr add 192.168.1.10/24 dev eth0sudo ip addr del 192.168.1.10/24 dev eth0sudo ip link set eth0 upsudo ip link set eth0 downsudo ip route add default via 192.168.1.1
Temporary changes made with ip are lost when the system reboots or the network service restarts. Always follow up with a persistent configuration (Netplan or NetworkManager) if you need the settings to survive.
Run sudo netplan try before sudo netplan apply to test the configuration with an automatic rollback after 120 seconds. This prevents you from locking yourself out of a remote machine if the new settings are incorrect.
Desktop systems and many cloud images use NetworkManager. The nmcli command-line tool lets you inspect and modify connections without a GUI.
nmcli device statusnmcli connection shownmcli connection up "My Connection"nmcli con mod "My Connection" ipv4.addresses 192.168.1.100/24nmcli con mod "My Connection" ipv4.gateway 192.168.1.1nmcli con mod "My Connection" ipv4.method manual
After modifying a connection, bring it back up to apply the changes:
Prefer ss over netstat on modern systems — it is faster, reads directly from kernel socket structures, and is actively maintained. netstat requires the net-tools package and is considered legacy.