ip / nmcli (Network Interface Management)
The ip command is the standard tool for managing Linux kernel network settings. It handles checking, adding, and removing IP addresses, manipulating the routing table, and enabling or disabling network interfaces — all in one tool. It is the successor to the older ifconfig and route commands. In contrast, nmcli is a command-line interface for NetworkManager, and its key advantage over ip is that changes are persistent — they survive a reboot. For production environments such as setting a static IP on a server, nmcli is the standard approach.
Syntax
# -----------------------------------------------
# ip addr — Check, add, and remove IP addresses
# -----------------------------------------------
# ip addr show [{interface}]
# → Shows IP addresses for all interfaces (or a specific one)
# Example: ip addr show
# Example: ip addr show eth0
# ip addr add {IP address}/{prefix length} dev {interface}
# → Adds an IP address to an interface (lost after reboot)
# Example: sudo ip addr add 192.168.1.100/24 dev eth0
# ip addr del {IP address}/{prefix length} dev {interface}
# → Removes an IP address from an interface
# Example: sudo ip addr del 192.168.1.100/24 dev eth0
# -----------------------------------------------
# ip link — Enable and disable interfaces
# -----------------------------------------------
# ip link show [{interface}]
# → Shows interface state (UP/DOWN), MAC address, and other info
# ip link set {interface} up
# → Enables the interface
# Example: sudo ip link set eth0 up
# ip link set {interface} down
# → Disables the interface
# Example: sudo ip link set eth0 down
# -----------------------------------------------
# ip route — View and manage the routing table
# -----------------------------------------------
# ip route show
# → Displays the current routing table
# ip route add {destination network} via {gateway} [dev {interface}]
# → Adds a static route (lost after reboot)
# Example: sudo ip route add 10.0.0.0/8 via 192.168.1.1 dev eth0
# ip route del {destination network}
# → Removes a static route
# Example: sudo ip route del 10.0.0.0/8
# ip route add default via {gateway}
# → Sets the default gateway
# Example: sudo ip route add default via 192.168.1.1
# -----------------------------------------------
# ip neigh — View the ARP table
# -----------------------------------------------
# ip neigh show
# → Displays the ARP table (IP address to MAC address mappings)
# -----------------------------------------------
# nmcli — NetworkManager command-line interface
# -----------------------------------------------
# nmcli device show [{interface}]
# → Shows detailed device info (IP address, DNS, etc.)
# nmcli device status
# → Lists the connection status of all devices
# nmcli connection show
# → Lists all defined connections (connection profiles)
# nmcli connection show {connection name}
# → Shows all settings for a specific connection
# nmcli connection modify {connection name} {property} {value}
# → Modifies a connection setting (persists after reboot)
# Example: sudo nmcli connection modify "ens3" ipv4.addresses "192.168.1.100/24"
# nmcli connection up {connection name}
# → Activates (applies) the connection
# nmcli connection down {connection name}
# → Deactivates the connection
# nmcli connection reload
# → Reloads connection configuration files
Command Reference
| Command | Description |
|---|---|
ip addr show | Displays IP addresses for all interfaces. You can specify an interface name to filter the output. |
ip addr add {IP}/{prefix} dev {IF} | Temporarily adds an IP address to an interface. The setting is lost after a reboot. |
ip addr del {IP}/{prefix} dev {IF} | Removes an IP address from an interface. |
ip link show | Displays interface state (UP/DOWN), MAC address, and MTU. |
ip link set {IF} up | Enables the interface. |
ip link set {IF} down | Disables the interface. |
ip route show | Displays the routing table. You can check the default gateway and static routes. |
ip route add {net} via {gw} | Temporarily adds a static route. The setting is lost after a reboot. |
ip route del {net} | Removes a static route. |
ip route add default via {gw} | Sets the default gateway. |
ip neigh show | Displays the ARP table. You can check the MAC addresses of hosts on the same network segment. |
nmcli device status | Lists the connection status of all network devices. |
nmcli device show {IF} | Displays detailed device info including IP address, gateway, and DNS. |
nmcli connection show | Lists all defined connections (connection profiles). |
nmcli connection modify {name} {prop} {val} | Modifies a connection setting. Changes are persistent. |
nmcli connection up {name} | Applies the updated settings to the system. |
nmcli connection down {name} | Deactivates the connection. |
nmcli connection reload | Reloads configuration files. Use this after manually editing a configuration file. |
Examples
Checking IP addresses and routing
# ----------------------------------------------- # Check the network state on the server # ----------------------------------------------- # Show IP addresses for all interfaces ip addr show # Show the routing table (check where the default gateway points) ip route show # Show the ARP table (check MAC addresses of hosts on the same segment) ip neigh show
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:ab:cd:ef brd ff:ff:ff:ff:ff:ff
inet 192.168.1.10/24 brd 192.168.1.255 scope global eth0
valid_lft forever preferred_lft forever
$ ip route show
default via 192.168.1.1 dev eth0 proto static metric 100
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.10 metric 100
$ ip neigh show
192.168.1.1 dev eth0 lladdr 00:1a:2b:3c:4d:5e REACHABLE
192.168.1.20 dev eth0 lladdr 00:1a:2b:3c:4d:6f STALE
Setting a static IP address with nmcli (persistent)
# ----------------------------------------------- # Set a static IP address on the server # (settings persist after reboot) # ----------------------------------------------- # First, check the current connection name and device name nmcli connection show # Check the current settings for the target connection nmcli connection show "eth0" # Change the IP assignment method to static (manual) sudo nmcli connection modify "eth0" ipv4.method manual # Set the static IP address and prefix length sudo nmcli connection modify "eth0" ipv4.addresses "192.168.1.50/24" # Set the default gateway sudo nmcli connection modify "eth0" ipv4.gateway "192.168.1.1" # Set the DNS servers (use commas to specify multiple) sudo nmcli connection modify "eth0" ipv4.dns "8.8.8.8,8.8.4.4" # Apply the settings to the system sudo nmcli connection up "eth0" # Verify the settings were applied nmcli device show eth0
$ nmcli device show eth0 GENERAL.DEVICE: eth0 GENERAL.TYPE: ethernet GENERAL.HWADDR: 52:54:00:AB:CD:EF GENERAL.MTU: 1500 GENERAL.STATE: 100 (connected) GENERAL.CONNECTION: eth0 IP4.ADDRESS[1]: 192.168.1.50/24 IP4.GATEWAY: 192.168.1.1 IP4.ROUTE[1]: dst = 0.0.0.0/0, nh = 192.168.1.1, mt = 100 IP4.ROUTE[2]: dst = 192.168.1.0/24, nh = 0.0.0.0, mt = 100 IP4.DNS[1]: 8.8.8.8 IP4.DNS[2]: 8.8.4.4
Overview
The ip command is part of the iproute2 package and comes pre-installed on all major Linux distributions. Learning just three subcommands — ip addr, ip link, and ip route — covers the vast majority of everyday network tasks. However, changes made with ip are volatile and do not survive a reboot. For permanent configuration changes on a production server, the correct approach is to use nmcli connection modify and then apply with nmcli connection up. If you are connected via SSH, double-check your settings before applying — changing the IP address or gateway incorrectly will drop your connection. For checking port and socket status, see netstat / ss. For firewall configuration, see firewalld or ufw.
If you find any errors or copyright issues, please contact us.