sudo route add default gw 192.168.100.1
However when power was lost or I rebooted then I would be back to having network connection problems, which is an issue when trying to automate something.
The solution that I found was to edit the /etc/dhcpcd.conf file using the following command:
sudo nano /etc/dhcpcd.conf
Then at the bottom of the file I added the following line:
static routers=192.168.100.1
Note that if you have the same problem, your IP address might need to be different. If you enter the command ifconfig, you should get an output similar to the following:

You need to look at the section for the network you are expecting to connect to. wlan0 is provided from the built in wifi hardware which comes on the newer raspberry pis. eth0 is the ethernet connection (wired). lo is the localhost which won't be the one that you need. I was connecting with eth0, so I looked under this section at the inet addr parameter, and I tool this number and changed the last digit to a 1, which is how I got my default gateway.
The file /etc/network/interfaces did not seem to make a difference to anything. Now the only command specifically for the eth0 connection is the following:
iface eth0 inet dhcp
There are a couple of other things that I had tried with no luck.
I tried writing a shell script to add the default gateway, and then tried to use crontab to run this at reboot using the @reboot command. This did not work for some reason. Running the shell script alone was fine but it was not possible for crontab to do this. I also tried adding in a 60 second pause in the crontab before the script was ran, but this also did not work.
I also tried making modifications to the /etc/network/interfaces file, which also did not help.
I tried the following commands together as a pair:
post-up route add default gw 192.168.100.1 eth0
pre-down route del default gw 192.168.100.1 eth0
This did nothing of course. Neither did adding a line with the gateway parameter.
gateway 192.168.100.1
So all in all I'm not sure exactly where the problem came from, just I now know the /etc/network/interfaces file is the wrong place to try and fix this, and instead it needs to be changed in /etc/dhcpcd.conf