To check your default route enter

As show above I have three physical interfaces, one outward facing and two to internal networks.  The default route dropped on the network when a connection was reset, causing the rest of my network to operate normally, with only this machine not knowing where to reach the Internet. For the machine to be able to reach the Internet it needs to have a default route which can be added with the following command If you have this problem arise more than once or twice, it can become a nuisance, so I have a written a couple of shell scripts to quickly rectify the situation. The first script will fetch your current ip for you.  I have $INTF set as STDIN, you change it to your specific interface if you don’t want to enter the interface name. Using your favorite text editor, I like vim and have a source folder in my home directory #!/bin/bash vim getip.sh #fetch ip address set for given device INTF=${1} PTH=(~/src/) declare TMP_IP2 TMP_IP2=$(ip a | grep ${INTF} | grep inet | cut -d” ” -f6 | cut -d “/” -f1 > ${PTH}current_${INTF}.ip) ip a | grep ${INTF} | grep inet | cut -d” ” -f6 | cut -d “/” -f1 | cut -d”.” -f1-3 | awk ‘{print $0″.0/24″}’ > ${PTH}net_${INTF}.ip ip a | grep ${INTF} | grep inet | cut -d” ” -f6 | cut -d “/” -f1 | cut -d”.” -f1-3 | awk ‘{print $0″.1″}’ > ${PTH}gw_${INTF}.ip declare TMP_IP TMP_IP=$(cat ${PTH}current_${INTF}.ip) echo “current wan ip $TMP_IP” Save and exit, make it executable, and then test it.

bash getip.sh eth0.2 Assuming that worked properly for you go ahead and copy it into /usr/local/bin/ to make it globally executable. Now I can simply type getip eth0.2 and the ip will be returned. The second script will assign the default route, as well as running the first script. vim setip.sh #!/bin/bash getip ${1} #fetch ip address set for given device PTH=(~/src/) declare RT_IP RT_IP=$(cat ${PTH}gw_${1}.ip) ip route change default via $RT_IP ip route add default via $RT_IP echo “ip route — default via $RT_IP” Save and quit.  You might have noticed that I have both change and add default route, this is for occasions that you have the wrong gateway set.

sudo setip.sh eth0.2 You can check the routing table again to double check that all is good. You can copy the scripts into /usr/local/bin/ if you would like them to be globally executable.  It will still require sudo, as you are modifying and interface.

Ubuntu 18.04 LTS Bionic Beaver Officially Available for Ubuntu, Kubuntu,…What is ‘Modern Setup Host’ and How to Fix High Disk Usage by Modern Setup Host?How to Fix No Route Error on DiscordHow to: Create an Ubuntu Bootable USB on Mac, Windows or Ubuntu Fix  Failed No Route to Host On Ubuntu With Multiple Networks - 85Fix  Failed No Route to Host On Ubuntu With Multiple Networks - 35Fix  Failed No Route to Host On Ubuntu With Multiple Networks - 22