Unable to add route with a specific gateway IP

Hi,

This is the routing table on a RHEL 7 server :

[root@SIEMsmartcon3 ~]# route -n
Kernel IP routing table
Destination	Gateway		Genmask		Flags	Metric	Ref	Use Iface
0.0.0.0		10.132.81.145	0.0.0.0		UG	100	0	0   eno49
10.132.81.144	0.0.0.0		255.255.255.240	U	100	0	0   eno49
169.254.0.0	0.0.0.0		255.255.0.0	U	100	0	0   eno49		
169.254.0.0	0.0.0.0		255.255.0.0	U	1003	0	0   eno50

I tried to add a route like this, however as shown an error is thrown :

[root@SIEMsmartcon3 ~]# ip route add 10.132.81.160/28 via 10.132.81.161 dev eno50
RTNETLINK answers: Network is unreachable

The 10.132.81.161 gateway is used as a gateway for another interface in the server (eno50).
Why is the error above thrown when I try to add that line? Is it because that gateway is not initiated as a default gateway in the routing table?

Are you sure you want to add the network on that host? The ...160 is outside your subnet, so you must route through ...145 , the default gateway. Please post the output of arp -a or arp -e of the two nodes on your LAN segment.

Hi,

Thank you for your reply. However, there are no two servers involved, only one. These are the outputs requested :

[root@SIEMsmartcon3 ~]# arp -a
? (10.132.81.164) at 00.17:a4:77;a4:56 [ether] on eno50
? (10.132.81.162) at ec:eb:b8:9f:01:26 [ether] on eno50
? (10.132.81.161) at 00:10:db:ff:20:04 [ether] on eno50 gateway (10.132.81.145) at 00:10:db:ff:20:04 [ether] on eno49
? (10.132.81.147) at 00:17:a4:77:a4:52 [ether] on eno49

[root@SIEMsmartcon3 ~]# arp -e
Address		HWtype	HWaddress		Flags Mask	Iface
10.132.81.164	ether	00:17:a4:77:a4:56	C		eno50
10.132.81.162	ether	ec:eb:b8:9f:01:26	C		eno50
10.132.81.161	ether	00:10:db:ff:20:04	C		eno50
gateway		ether	00:10:db:ff:20:04	C		eno49
10.132.81.147	ether	00:17:a4:77:a4:52	C		eno49

Best Regards,
anaigini45

I'm a bit puzzled. Did you use "alias interfaces", as both seem to share the same MAC address? Pls show the output from ifconfig or its ip equivalent.

According to your routing table the IP-Network for the gateway (10.132.81.161) is connected via NIC eno50 . But the route-setup command points to NIC eno49 .

Maybe you should just omit the dev eno50 in your route command or change your ip configuration so that 10.31.181... is configured to eno50 instead of eno49.

And yes /28 is smaller than expected. As RudiC said the gateway is outside your subnet anyway. The gateway must be located within one of the configured subnets of your server.