To add a static route to the network configuration on an Ubuntu Linux system, you can use the route
command.
To add a static route, you will need to specify the destination network, the gateway to use for the route, and the network interface that the route should be associated with. For example, to add a static route to the 192.168.1.0/24
network via the gateway 192.168.0.1
on the eth0
interface, you can use the following command:
sudo route add -net 192.168.1.0/24 gw 192.168.0.1 dev eth0oSurce:www.lautturi.com
This will add the static route to the system's routing table.
To make the static route persist across reboots, you can add the route to the /etc/network/interfaces
file. For example, to add the above route to the eth0
interface configuration, you can add the following lines to the /etc/network/interfaces
file:
up route add -net 192.168.1.0/24 gw 192.168.0.1 dev eth0 down route del -net 192.168.1.0/24 gw 192.168.0.1 dev eth0
This will cause the route to be added when the eth0
interface is brought up, and removed when the interface is brought down.
Keep in mind that the above steps assume that you are using the /etc/network/interfaces
file to configure the network interfaces. If you are using a different method to configure the network, the steps may be different.
For more information on configuring static routes on Ubuntu Linux, you can refer to the route
man page or the Ubuntu documentation.