ip Command in Linux: Addresses, Links, Routes, and Troubleshooting

ip from iproute2 configures addresses, links, and routes on Linux. Subcommands ip addr, ip link, and ip route replace legacy ifconfig and route for day-to-day network inspection and temporary changes.

Published

Updated

Read time 9 min read

Reviewed byDeepak Prasad

ip Command in Linux: Addresses, Links, Routes, and Troubleshooting
About ip from iproute2 configures addresses, links, and routes on Linux. Subcommands ip addr, ip link, and ip route replace legacy ifconfig and route for day-to-day network inspection and temporary changes.
Tested on Ubuntu 25.04 (Plucky Puffin); iproute2 6.14.0; kernel 7.0.0-27-generic
Package iproute2
Man page ip(8)
Privilege root / sudo for changes (show works as user)
Distros

iproute2 on modern Linux (Ubuntu, Debian, RHEL, Fedora, SUSE, Arch, and others).

Persistent config: nmcli examples or distro network config files.

ip — quick reference

Addresses (ip addr)

View and assign IPv4/IPv6 addresses on interfaces.

When to use Command
Brief list of interfaces and addresses ip -br addr show
Full details for one interface ip addr show dev enp0s3
IPv4 addresses only ip -4 addr show
Add an address (temporary until reboot) sudo ip addr add 192.168.1.10/24 dev enp0s3
Delete an address sudo ip addr del 192.168.1.10/24 dev enp0s3
Remove all addresses on an interface sudo ip addr flush dev enp0s3

Control interface state, MAC, and naming at the link layer.

When to use Command
List interfaces and link state ip link show
Bring interface up sudo ip link set enp0s3 up
Bring interface down sudo ip link set enp0s3 down
Show traffic statistics ip -s link show enp0s3
Set MAC address (temporary) sudo ip link set dev enp0s3 address 02:00:00:00:00:01

Routes (ip route)

Inspect and change the kernel routing table.

When to use Command
Show routing table ip route show
Which path kernel would use to reach an IP ip route get 8.8.8.8
Add default gateway sudo ip route add default via 192.168.1.1
Add network route sudo ip route add 192.168.99.0/24 via 10.0.2.2 dev enp0s3
Replace existing route sudo ip route replace default via 192.168.1.1
Delete a route sudo ip route del 192.168.99.0/24

Global output options

When to use Command
Brief one-line output ip -br link show
JSON output for scripts ip -j addr show
Numeric output (no name resolution) ip -N route get 8.8.8.8

Changes from ip addr, ip link, and ip route are runtime only — use NetworkManager or netplan for settings that survive reboot.


ip — command syntax

Top-level synopsis from ip help on Ubuntu 25.04 (iproute2 6.14.0):

text
Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }
where  OBJECT := { address | addrlabel | … | link | … | route | rule | … }
       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -br[ief] |
                    -4 | -6 | -j[son] | -o[neline] | … }

Common subcommand patterns:

text
ip address { add | del | show } … dev IFNAME
ip link set dev IFNAME { up | down } …
ip route { add | del | replace | show } …

ip — command examples

Essential List interfaces and addresses (-br addr)

Start every network check by seeing which interfaces exist and which addresses they hold.

Run the command:

bash
ip -br addr show

Sample output:

text
lo               UNKNOWN        127.0.0.1/8 ::1/128 
enp0s3           UP             10.0.2.15/24 fd17:625c:f037:2:…/64 … 
enp0s8           UP             192.168.0.4/24 fe80::…/64

The first column is the interface name; UP means the link is active. Use ip addr show dev IFACE when you need prefix length, scope, and secondary addresses.

Essential Add and remove an address on loopback

ip addr add is the standard way to assign a temporary address — safe to demo on lo in a lab.

Add a secondary loopback address:

bash
sudo ip addr add 127.0.0.2/8 dev lo
ip -4 addr show dev lo

Sample output:

text
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.0.0.2/8 scope host secondary lo
       valid_lft forever preferred_lft forever

Revert when done:

bash
sudo ip addr del 127.0.0.2/8 dev lo

Production changes on real NICs need matching subnet planning and often a persistent config layer (netplan, nmcli).

Essential See which route the kernel selects (route get)

ip route get shows the interface, gateway, and source address for a destination without sending packets.

Run the command:

bash
ip route get 8.8.8.8

Sample output:

text
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0 
    cache

Use this when ping works to one subnet but not another — it tells you whether policy routing or a missing default gateway is the issue.

Common Add and delete a static route

Static routes send traffic for a prefix through a specific gateway — common in split-tunnel VPN lab setups.

Add a test route:

bash
sudo ip route add 192.168.99.0/24 via 10.0.2.2 dev enp0s3
ip route show 192.168.99.0/24

Sample output:

text
192.168.99.0/24 via 10.0.2.2 dev enp0s3

Remove it:

bash
sudo ip route del 192.168.99.0/24

If via is unreachable, the kernel may reject the route — confirm gateway reachability with ip route get GATEWAY_IP.

Common Interface statistics (-s link)

Counters help spot dropped packets or a stuck interface.

Run the command:

bash
ip -s link show lo

Sample output:

text
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    RX:  bytes packets errors dropped  missed   mcast           
       4614855   14920      0       0       0       0 
    TX:  bytes packets errors dropped carrier collsns           
       4614855   14920      0       0       0       0

Rising errors or dropped on a physical NIC points to cable, driver, or ring-buffer issues — not just IP misconfiguration.

Advanced RTNETLINK: Address already assigned

Adding the same address twice returns an error — unlike ip route replace, add does not overwrite.

Run twice:

bash
sudo ip addr add 127.0.0.2/8 dev lo
sudo ip addr add 127.0.0.2/8 dev lo

Sample output on the second run:

text
Error: ipv4: Address already assigned.

Use ip addr del first, or ip addr replace when you intend to swap prefixes on an interface.

Advanced Read the full routing table

Before adding routes in rescue mode, snapshot what the kernel already knows.

Run the command:

bash
ip route show

Sample output (truncated):

text
default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 100 
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100 
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.4 metric 101

proto dhcp means NetworkManager or systemd-networkd installed the route — your manual ip route changes may disappear on DHCP renew unless made persistent elsewhere.


ip — when to use / when not

Use ip when Use something else when
  • You need to inspect addresses, links, or routes on a modern Linux kernel
  • You are in rescue mode or debugging and need temporary network changes
  • You want one tool instead of legacy ifconfig + route
  • Scripts need JSON (ip -j) or brief output (ip -br)
  • Settings must survive reboot on a desktop/server → nmcli, netplan, or ifcfg files
  • You only need DNS lookup → dig / resolvectl
  • You are testing reachability → ping, tracepath
  • Firewall policy → nft / iptables
  • Deep route policy tables → ip rule (outside this page's scope)

ip vs ifconfig

ip (iproute2) ifconfig (net-tools)
Status Actively maintained Legacy; often not installed
Scope addr, link, route, rule, netns, … Addresses and basic link flags
Output Brief, JSON, statistics Human-readable only
Scripts Preferred on current distros Avoid for new automation

Ubuntu and RHEL images increasingly omit ifconfig — use ip for portable admin work.


Command One line
ip Unified network configuration (this page)
ip route Deeper routing examples
ss Socket and connection listing
ping Test reachability after ip changes

Browse the full index in our Linux commands reference.


ip — interview corner

Why did Linux move from ifconfig to ip?

The kernel networking stack outgrew ifconfig — multiple addresses per interface, routing policy, namespaces, and VLANs need richer objects. ip from iproute2 maps directly to netlink messages the kernel expects.

A strong answer is:

"iproute2's ip command is the supported interface to the modern kernel — ifconfig is legacy net-tools and misses features like policy routing and JSON output."

Do ip addr changes persist across reboot?

No. Runtime ip changes live in memory until reboot or until NetworkManager/systemd-networkd reapplies its own config.

A strong answer is:

"ip changes are ephemeral — for persistence I use nmcli, netplan, or distro network files, and ip only for rescue or quick tests."

When is ip route get useful?

It resolves the forwarding decision for one destination — gateway, outgoing interface, and source IP — without traceroute.

bash
ip route get 8.8.8.8

A strong answer is:

"route get shows how the kernel would forward a packet to that destination — I use it to debug wrong source IP or missing gateway issues."

What does ip addr flush do?

It removes all addresses from an interface — destructive on production NICs, occasionally useful in labs or when resetting a bridge.

A strong answer is:

"flush strips every address from the device — I use it carefully, usually only in test environments or before rebuilding a bridge config."


Troubleshooting

Symptom Likely cause Fix
Error: ipv4: Address already assigned Duplicate ip addr add ip addr del or use replace
RTNETLINK answers: File exists Route already present ip route del then add, or ip route replace
Cannot find device Wrong interface name ip link show — use current predictable names (enp0s3)
Cannot assign requested address Interface down or bad prefix ip link set IFACE up; check CIDR
Changes vanish after reboot Runtime-only ip commands Persist with nmcli/netplan
No default route DHCP or config missing ip route add default via GW dev IFACE temporarily; fix persistent config

Deepak Prasad

R&D Engineer

Founder of GoLinuxCloud with more than 15 years of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive …