How Can I Add a Static Route to a CentOS 6.5 OS?
After the system restarts, non-static routes are lost, affecting network availability. To prevent this issue from occurring, you must add static routes to the system.
- Log in to the ECS.
- Create or modify the static route configuration file.
If the static-routes configuration file is not in the /etc/sysconfig/ directory, create this file. If such a file is available, run the following command to add a static route into this file:
any net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.34
After the configuration, save and exit the file. The following figure shows the modified file content.
- Run the following command to restart the network service to make the static route take effect:
service network restart
- Run the following command to view routes: