CentOS Linux: Add Static Routing

To add a static route on CentOS, you can use the route command. The basic syntax for adding a static route is as follows:

sudo route add -net [destination_network] netmask [mask] gw [gateway] dev [interface]

For example, if you want to add a static route for the network 192.168.100.0/24 through gateway 192.168.0.1, you can use the following command:

sudo route add -net 192.168.100.0 netmask 255.255.255.0 gw 192.168.0.1 dev eth0

This command will add a static route for the network 192.168.100.0/24 through the gateway 192.168.0.1 on the eth0 interface.

You can also add a persistent static route by adding the same command to the /etc/sysconfig/network-scripts/route-interface file, where interface is the name of the interface you want to add the route to. For example, to add a persistent route to the eth0 interface, you would add the above command to the file /etc/sysconfig/network-scripts/route-eth0.

(Clonazepam)

Leave a Comment