Linux ip Command Cheat Sheet

Adding a default route

ip route add default via <gateway ip>

Optionally with an interface

ip route add default via <gateway ip> dev <interface>

Adding a subnet route to an interface

ip route add <ip>/<mask> dev <interface>

Deleting a route

ip route del default
ip route del <ip addr>/<mask>

Checking a route

ip route get 8.8.8.8

Adding a static IP to an interface

ip addr add <ip addr>/<mask> broadcast <broadcast addr> dev <interface>

Removing a static IP from an interface

ip addr del <ip addr>/<mask> dev <interface>

Setting interfaces up/down

ip link set dev <interface> up
ip link set dev <interface> down