To set up or change default gateway, you can use ip command, route command or you can manually edit /etc/network/interfaces file.
Option 1: ip command
ip route add default via 10.0.0.1 |
Option 2: route command
route add default gw 10.0.0.1 |
To delete the default route,
route del default gw 10.0.0.1 |
Option 3: Save routing information to a configuration file /etc/network/interfaces
Open /etc/network/interfaces file
nano /etc/network/interfaces |
Find network interface and add the following option
... gateway 10.0.0.1 ... |
Save changes and restart networking
/etc/init.d/networking restart |
Other notes
In case you don’t have route command, you can get it via net-tools package.
sudo apt install net-tools |