A quick reference for the ip command โ modern Linux network configuration. Bookmark this page.
IP Addresses
# Show all addresses
ip addr show
ip a # Short form
# Show specific interface
ip addr show eth0
# Add IP address
sudo ip addr add 10.0.0.5/24 dev eth0
# Remove IP address
sudo ip addr del 10.0.0.5/24 dev eth0
# Flush all addresses on interface
sudo ip addr flush dev eth0Links (Interfaces)
# Show all interfaces
ip link show
ip link show eth0
# Bring interface up/down
sudo ip link set eth0 up
sudo ip link set eth0 down
# Set MTU
sudo ip link set eth0 mtu 9000
# Set MAC address
sudo ip link set eth0 address 00:11:22:33:44:55
# Create VLAN interface
sudo ip link add link eth0 name eth0.100 type vlan id 100Routes
# Show routing table
ip route show
ip route show table all
# Add route
sudo ip route add 10.1.0.0/16 via 10.0.0.1
sudo ip route add 10.1.0.0/16 via 10.0.0.1 dev eth0
# Add default gateway
sudo ip route add default via 10.0.0.1
# Delete route
sudo ip route del 10.1.0.0/16
# Show route to specific destination
ip route get 8.8.8.8Neighbors (ARP)
# Show ARP table
ip neigh show
ip neigh show dev eth0
# Add static ARP entry
sudo ip neigh add 10.0.0.100 lladdr 00:11:22:33:44:55 dev eth0
# Delete entry
sudo ip neigh del 10.0.0.100 dev eth0
# Flush ARP cache
sudo ip neigh flush allNetwork Namespaces
# List namespaces
ip netns list
# Create namespace
sudo ip netns add test-ns
# Run command in namespace
sudo ip netns exec test-ns ip addr show
# Connect namespaces with veth pair
sudo ip link add veth0 type veth peer name veth1
sudo ip link set veth1 netns test-nsMonitoring
# Monitor link changes
ip monitor link
# Monitor address changes
ip monitor address
# Monitor route changes
ip monitor route
# Monitor all changes
ip monitor allTips and Tricks
ipreplacesifconfig,route, andarpโ use it for all network operations- Use
ip -cfor colored output - Use
ip -jfor JSON output (scriptable):ip -j addr show | jq . - Use
ip -s link showfor interface statistics (packets, bytes, errors) - Changes via
ipare temporary โ use NetworkManager or/etc/network/interfacesfor persistence