ip command vs ifconfig: Modern Network Management
Replace deprecated ifconfig with the ip command to manage interfaces, addresses, routes, and tunnels on modern Linux distributions.
Netbay Engineering
Netbay Engineering
On this page
If you have been managing Linux servers for a while, you have probably typed ifconfig a thousand times. It worked, it was familiar, and it shipped with every distribution. But ifconfig belongs to the net-tools package, which has been deprecated across most major distributions for years. Ubuntu removed it by default starting with 18.04, and Fedora dropped it even earlier. The replacement is the ip command from the iproute2 suite, and it is far more powerful.
The ip command unifies interface configuration, address management, routing, tunneling, and neighbor table manipulation into a single binary. Where ifconfig only dealt with interfaces and addresses, and you needed route for routing and arp for the ARP table, ip covers all of that and more. Learning the ip command is not just about replacing one tool with another. It is about unlocking a more consistent and capable networking toolkit.
Listing Interfaces with ip link
The most basic operation is listing your network interfaces. With ifconfig you simply ran it with no arguments. With ip, the equivalent is ip link show.
ip link show
ip -s link show
ip -br link showThe -s flag adds statistics including packet counts, errors, and drops. The -br flag gives a compact, machine-readable one-line-per-interface output that is much easier to scan on a server with many virtual interfaces. You will notice that interfaces like lo, eth0, and docker0 all appear with their current state UP or DOWN.
Managing IP Addresses
With ifconfig you would assign an address like ifconfig eth0 10.0.0.5 netmask 255.255.255.0 up. The ip equivalent splits the concern into address assignment and link state management.
ip addr add 10.0.0.5/24 dev eth0
ip addr show dev eth0
ip addr del 10.0.0.5/24 dev eth0
ip link set eth0 up
ip link set eth0 downNotice the CIDR notation. The ip command uses prefix lengths like /24 instead of dotted netmasks. This is more concise and less error-prone. A single interface can hold multiple addresses, and you can manage each one independently. This is particularly useful when you are hosting multiple SSL certificates on different IPs or running services that bind to specific addresses.
The Neighbors Table
The arp command is replaced by ip neigh. You can inspect the ARP cache, add static entries, or flush stale entries with a simple subcommand.
ip neigh show
ip neigh add 10.0.0.10 lladdr 00:11:22:33:44:55 dev eth0
ip neigh flush dev eth0On a VPS with a single virtual NIC this is less critical, but in bridged or VLAN environments the neighbors table becomes important for understanding Layer 2 reachability.
Why ifconfig Output Is Misleading
One subtlety that trips up experienced admins is that ifconfig shows a zero-metric route for every address it configures. This hides routing problems. The ip command does not silently insert routes. If you need a route, you create it explicitly with ip route. This makes your networking configuration honest and debuggable.
If you are coming from a world where ifconfig eth0:0 created alias interfaces, the ip command replaces that with simply adding another address to the same device. Virtual interfaces created with ifconfig aliases are an artifact of the past. The modern approach is cleaner.
Practical Scripting Example
Here is a small script that discovers the primary interface, assigns an IP from a variable, and brings the link up. It uses the compact output format and works on any modern distribution.
#!/bin/bash
IFACE=$(ip -br link show | awk '$1 != "lo" && $2 == "UP" {print $1; exit}')
IP_ADDR="$1"
CIDR="$2"
if [ -z "$IFACE" ] || [ -z "$IP_ADDR" ] || [ -z "$CIDR" ]; then
echo "Usage: $0 <ip-address> <cidr>"
exit 1
fi
ip addr add "$IP_ADDR/$CIDR" dev "$IFACE" 2>/dev/null || ip addr replace "$IP_ADDR/$CIDR" dev "$IFACE"
ip link set "$IFACE" up
echo "Assigned $IP_ADDR/$CIDR to $IFACE"The replace subcommand is a safety net. If the address already exists, it updates instead of failing. This makes idempotent network scripts much easier to write.
When to Keep ifconfig Around
There is no shame in having net-tools installed as a fallback. Some legacy monitoring scripts, older documentation, and third-party tools still reference ifconfig. You can install it on Ubuntu or Debian with apt install net-tools. But every new script you write should use ip. The output is more predictable, the error messages are clearer, and the feature set covers everything net-tools provides and much more.
If you want to practice on a fresh instance, you can spin up an Ubuntu 24.04 VPS on Netbay in under 60 seconds and follow along at netbayhosts.in.
Keep reading
Follow along on a real VPS
Deploy Linux in under 60 seconds
These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.
Deploy an instance