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
sudo ip route add `a.b.c.d/e` via `gateway_IP` dev `device_name`
a.b.c.d/ecan be the subnet of IPs or just an IP address of the desired destination, and the
gateway_IPis the IP address of the gateway where you want to route your traffic through (e.g.,
device_nameis the name of the interface via which you want to route your traffic (e.g.).
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
chainthe above command with
sudo service NetworkManager restartto reboot network, thus gaining back access to the machine immediately. Note: make sure you have
NetworkManageron your machine.