Notes - IP commands

Follows are command lines that I often use (not necessarily the best approach) while interacting with ip, which is used to show / manipulate routing, devices, policy routing and tunnels.

  • Show current routes.

    ip route show
  • Add route:

    sudo ip route add `a.b.c.d/e` via `gateway_IP` dev `device_name`

    a.b.c.d/e can be the subnet of IPs or just an IP address of the desired destination, and the gateway_IP is the IP address of the gateway where you want to route your traffic through (e.g.,, and device_name is the name of the interface via which you want to route your traffic (e.g.).

  • Delete route:

    ip route del `a.b.c.d/e`
  • Remove an interface/device:

    ip link set dev `interface_name` down


    ip link delete `interface_name`
  • Flush current ip table (CAUTION! you may be kicked out from machine if you don’t have other means of accessing it, e.g. console, physical access, etc):

    sudo ip route flush table main

    You may want to chain the above command with sudo service NetworkManager restart to reboot network, thus gaining back access to the machine immediately. Note: make sure you have NetworkManager on your machine.