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 |
Links (ip link)
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):
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:
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:
ip -br addr showSample output:
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::…/64The 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 Inspect link layer state
Link state must be UP before addresses on that interface are usable.
Run the command:
ip link show enp0s3Sample output:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:26:59:37 brd ff:ff:ff:ff:ff:ff
altname enx080027265937LOWER_UP means the cable or virtual link has carrier. If you see state DOWN, bring the interface up before adding routes through it.
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:
sudo ip addr add 127.0.0.2/8 dev lo
ip -4 addr show dev loSample output:
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 foreverRevert when done:
sudo ip addr del 127.0.0.2/8 dev loProduction 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:
ip route get 8.8.8.8Sample output:
8.8.8.8 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 0
cacheUse 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 Bring loopback down and up
Rescue shells and container hosts sometimes need you to toggle link state manually.
Run the commands on loopback (lab only — do not leave lo down on a production box):
sudo ip link set lo down
ip link show lo | head -1
sudo ip link set lo up
ip link show lo | head -1Sample output:
1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000On physical NICs use the real name from ip link (enp0s3, eth0, …) instead of lo.
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:
sudo ip route add 192.168.99.0/24 via 10.0.2.2 dev enp0s3
ip route show 192.168.99.0/24Sample output:
192.168.99.0/24 via 10.0.2.2 dev enp0s3Remove it:
sudo ip route del 192.168.99.0/24If 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:
ip -s link show loSample output:
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 0Rising 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:
sudo ip addr add 127.0.0.2/8 dev lo
sudo ip addr add 127.0.0.2/8 dev loSample output on the second run:
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:
ip route showSample output (truncated):
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 101proto 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 |
|---|---|
|
|
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.
Related commands
| 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.
ip route get 8.8.8.8A 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 is the difference between ip link and ip addr?
ip link is layer 2 — NIC up/down, MAC, mtu. ip addr is layer 3 — IPv4/IPv6 addresses bound to that interface.
A strong answer is:
"link manages the interface device; addr manages IP addresses on it — both must be correct before traffic flows."
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 |

