ip Cheat Sheet

The iproute2 suite — addresses, routes, links, neighbors, and namespaces in one command.

Networking3 sections · 21 commands
⌘K

Addresses

6
ip addr

All interfaces and addresses

ip addr show eth0

One interface

ip addr add 10.0.0.5/24 dev eth0

Add an address

ip addr del 10.0.0.5/24 dev eth0

Remove an address

ip -4 addr

IPv4 only

ip -6 addr

IPv6 only

Routes

7
ip route

Show the routing table

ip route show default

Default gateways

ip route add default via 10.0.0.1

Set the default gateway

ip route add 192.168.50.0/24 via 10.0.0.2

Add a static route

ip route del 192.168.50.0/24

Delete a route

ip route get 8.8.8.8

Which route wins for an IP

ip route replace default via NEWGW

Replace the default route

Links & Neighbors

8
ip link

All interfaces with states

ip link set eth0 up/down

Bring an interface up or down

ip link set eth0 mtu 9000

Change MTU

ip neigh

ARP/NDP table

ip neigh flush all

Clear the neighbor cache

ip link add br0 type bridge

Create a bridge

ip netns add NAME

Create a network namespace

ip netns exec NAME ip addr

Run a command in a namespace