Linux ip cheat sheet

ip link show

Display ip addresses

ip addr show

Bring interface up

ip link set eth0 up

Bring interface down

ip link set eth0 down

Assign IP to device eth0

ip addr add 192.168.0.2 dev eth0

Assign IP to device including netmask and broadcast

ip addr add 192.168.0.2/24 broadcast 192.168.0.255 dev eth0

Delete IP from device

ip addr del 192.168.0.2/24 dev eth0

Add IP as alias

ip addr add 192.168.1.2/24 dev eth0 label eth0:1

Get route for IP

ip route get 192.168.0.10

Add route for subnet

ip route add 192.168.0.0/24 dev eth0

Delete route for subnet

ip route del 192.168.0.0/24 dev eth0

Add route via Gateway IP

ip route add 192.168.0.0/24 via 192.168.0.1

 Share!