Skip to main content
FortiKoala
Staff
Staff
October 1, 2018

Technical Note: How to Add a Host Route in CentOS7

  • October 1, 2018
  • 0 replies
  • 7915 views
Description
How to Add a Host Route in CentOS7

Scope
Version:   CentOS7
Solution
Version:  CentOS7

Host Routes define which interface Network Sentry uses to send traffic to a specific IP address. 


Solution:

Add host route temporarily
ip route add <host IP addr>/32 via <gateway IP addr> dev <eth interface>


Example of result:
> ip route add 11.11.11.11/32 via 192.168.8.1 dev eth 0
> route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.8.1     0.0.0.0         UG    0      0        0 eth0
11.11.11.11     192.168.8.1     255.255.255.255 UGH   0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0


This route will be removed under the following circumstances.

1.  A reboot of Network sentry
2.  A restart of the network (service network restart)


To delete a host route:
ip route del <host IP addr>/32 via <gateway IP addr> dev eth0

Example of result:
> route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.8.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
192.168.8.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0



Make the host route permanent by editing /etc/sysconfig/static-routes file:
any host <host IP addr>//32 gw <gateway IP addr>

Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!