How to add a static route to a host-routed Linux VPS

Since routing for host-routed VPS is done at the hypervisor level, the static route has to be added to hypervisor.

Assuming that the hypervisor interface eth0/IP1 and the IP_GW is the IP of the destination

 

# ip route add A.B.C.D/N via IP_GW dev eth0

 

In order to make this permanent we create the following file and restart the network service

 

/etc/sysconfig/network-scripts/route-eth0

 

and add this line to the file /etc/sysconfig/network-scripts/route-eth0

 

A.B.C.D/N via IP_GW