Temporary Static Route
To test a static route you can issue the following command from the ComXchange CLI.
Note: This will not survive a reboot
- To route to a network use the command: ip route add X.X.X.X/X via Y.Y.Y.
- Where X.X.X.X/X is the network you want to route to and Y.Y.Y.Y is the IP address that the route will go through
- Example: ip route add 172.16.0.0/24 via 192.168.254.254
- To route a specific ip address you can use the ip address with a /32
- Example: ip route add 172.16.16.30/24 via 192.168.254.254
Persistent Static Route
To Add a persistent static route which will survive a reboot you will need to create a routing file in the /etc/sysconfig/network-scripts directory for the interface that the route needs to go out such as eth0 then add the route information.
- Edit /etc/sysconfig/network-scripts/route-eth0
- Add the route information for a network or an individual IP address
- X.X.X.X/X via Y.Y.Y.Y where X.X.X.X/X is the network you want to route to and Y.Y.Y.Y is the IP address that the route will go through
- Example: 172.16.0.0.0/24 via 192.168.254.254
Persistent Static Routewith OpenVPN
If you are using OpenVPN you will need to add the static route similar to the persistent route created in the /etc/sysconfig/network-scripts/route-eth0 file to the file /etc/openvpn/openvpn-startup file so the route will be created when the OpenVPN service starts.- Edit the /etc/openvpn/openvpn-startup file and add the following ip route command to the bottom of the file and save
- ip route add X.X.X.X/X via Y.Y.Y.Y where X.X.X.X/X is the network you want to route to and Y.Y.Y.Y is the IP address that the route will go through
- Example: ip route add 172.16.0.0/24 via 192.168.254.254