Interfaces & addresses: ip
ip shows and configures network interfaces and addresses on modern Linux.
Syntax
ip addr
ip routeip is the modern tool for viewing your network setup, replacing the older ifconfig. The most common use is simply reading your addresses.
Everyday commands
ip addr(orip a) — show all interfaces and their IP addresses.ip route— show the routing table, including the default gateway.ip link— list network interfaces and whether they are up.
The loopback interface lo with address 127.0.0.1 always points back to your own machine.
Example
# Show interfaces and their IP addresses
ip addr
# 2: eth0: ... inet 192.168.1.42/24 ...
# Short form
ip a
# Show the default gateway / routing
ip route
# default via 192.168.1.1 dev eth0
# Find your public IP via a web service
curl ifconfig.meWhen to use it
- A sysadmin runs 'ip addr show eth0' to find the assigned IP address of a new cloud instance before configuring DNS.
- A network engineer adds a temporary IP to an interface with 'ip addr add 10.0.0.5/24 dev eth1' for testing without editing config files.
- A DevOps engineer uses 'ip route show' to diagnose routing issues when traffic is not reaching the correct gateway.
More examples
Show network interfaces and IPs
Shows ip addr to list interfaces and their assigned IPv4/IPv6 addresses; a modern alternative to ifconfig.
# Show all interfaces
ip addr show
# Show a specific interface
ip addr show eth0
# 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP>
# inet 192.168.1.10/24 brd 192.168.1.255Inspect routing table
Uses ip route to show the routing table and ip route get to trace the path a packet would take to a host.
ip route show
# default via 192.168.1.1 dev eth0
# 192.168.1.0/24 dev eth0 proto kernel scope link
# Show route a specific destination would use
ip route get 8.8.8.8
# 8.8.8.8 via 192.168.1.1 dev eth0Bring interface up or down
Uses ip link to toggle a network interface's state, useful for applying new IP configurations or troubleshooting.
# Bring an interface down
sudo ip link set eth1 down
# Bring it back up
sudo ip link set eth1 up
# Show link state of all interfaces
ip link show
Discussion