IP and Routing: The ip Command
The ip command is the modern replacement for ifconfig, route, and several other older tools. It’s been the standard on Linux for over a decade. If you still use ifconfig, learn ip — it’s faster, more capable, and what every modern doc references.
Show all interfaces and addresses
ip a # show all addresses (most common)
ip addr # same thing, longer form
ip -br a # brief table view
ip -c a # colored output
ip -4 a # only IPv4
ip -6 a # only IPv6
Output gives you each interface with its IP, MAC, MTU, and state.
Show just one interface
ip a show eth0
ip a show wlan0
Bring an interface up or down
sudo ip link set eth0 up
sudo ip link set eth0 down
ip link # show all links (interfaces) and their states
ip -br link # brief view
Add or remove an IP address
# Add an IP (temporary — gone on reboot)
sudo ip addr add 192.168.1.50/24 dev eth0
# Remove
sudo ip addr del 192.168.1.50/24 dev eth0
Permanent changes belong in your distro’s network config (Netplan on Ubuntu, NetworkManager / nmcli on Fedora, /etc/network/interfaces on plain Debian).
Show routing table
ip route # show routes (most common)
ip r # short form
ip -4 r # IPv4 routes
ip route get 8.8.8.8 # how would I reach this IP?
Sample output:
default via 192.168.1.1 dev wlan0
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.42
The first line is the default route — anything not matching another route goes here.
Add or change a route
# Add a static route to 10.0.0.0/8 via gateway
sudo ip route add 10.0.0.0/8 via 192.168.1.254
# Change the default gateway
sudo ip route del default
sudo ip route add default via 192.168.1.1
# Remove a route
sudo ip route del 10.0.0.0/8
ARP table (who has which IP)
ip neigh # show ARP table
ip n # short
arp -a # legacy command, still works
Bridges, VLANs, namespaces (advanced)
ip link add br0 type bridge # create a bridge interface
ip link add link eth0 name eth0.10 type vlan id 10 # VLAN 10 on eth0
ip netns add mynamespace # network namespace
NetworkManager command-line: nmcli
If your system uses NetworkManager (most desktops, Fedora, Ubuntu Desktop), nmcli is the way to make persistent changes:
nmcli device # list devices and state
nmcli connection show # configured connections
nmcli connection up "MyWiFi"
nmcli device wifi list # scan
nmcli device wifi connect "SSID" password "yourpass"
Useful one-liners
# Get YOUR machine's primary IP
ip route get 1.1.1.1 | awk 'NR==1 {print $7}'
# Find your default gateway
ip route | awk '/default/ {print $3}'
# Find your active interface name
ip route | awk '/default/ {print $5}'
# Get external (public) IP
curl -s ifconfig.me
Common mistakes
- Editing IP with
ip addr addand expecting it to survive reboot — it doesn’t. Use your distro’s permanent config. - Using
ifconfigon a server where it’s no longer installed — switch toip a. - Confusing
ip a(addresses) withip link(interfaces) — they show overlapping but different info.
What to learn next
Once you can read IPs, the next concern is sockets and ports — what’s listening, what’s connected. The ss command handles that.