User Tools

Site Tools


adding_routes

Adding Routes


CentOS 6.x

To add a route, you can use the following command and replacing <destination>, <gateway>, <interface>:

ip route add <destination>/32 via <gateway> dev <interface>

Once you have confirmed the route is working, you will need to add it to configuration file to make sure the route survives a reboot. Replace <interface> with the interface name
vim /etc/sysconfig/network-scripts/route-<interface>

Once you are in the file, add the route like you did above without the commands:
<destination>/32 via <gateway> dev <interface>

You could instead, add the route straight into the configuration file and then run the following command to test the file:
/etc/sysconfig/network-scripts/ifup-routes <interface name>

Testing the interface

ip route get <destination>

adding_routes.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1