1
[root@hng1 ~]# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
9.9.9.0         0.0.0.0         255.255.255.0   U         0 0          0 ens7
10.21.0.0       0.0.0.0         255.255.0.0     U         0 0          0 ens4
10.31.0.0       0.0.0.0         255.255.0.0     U         0 0          0 ens5
10.41.0.0       0.0.0.0         255.255.0.0     U         0 0          0 ens6
10.61.0.0       0.0.0.0         255.255.0.0     U         0 0          0 ens3
[root@hng1 ~]#
[root@hng1 ~]# ip route add 10.21.0.0/16 via 10.21.0.1
RTNETLINK answers: Network is unreachable

The network has four switches. All interfaces with address 10.21.x.x/16 go into one switch which is connected to gateway 10.21.0.1. Similarly all interfaces with address 10.31.x.x/16 goes into second switch which is connected to the same gateway at interface 10.31.0.1 .... And so on..

  • Route you want to add is already present in routing table. PS. Switch DO NOT have IP address. It's not a router. – Akina Jun 13 '18 at 15:27

1 Answers1

1

The route is rejected because it describes an infinite loop. If you want to reach 10.21.0.0/16 via 10.21.0.1, then what route do you use to reach 10.21.0.1 itself?

The route is also completely redundant – according to your routing table, you are already in the 10.21.0.0/16 subnet and have an "on-link" route to it, so all hosts are reachable directly – there is no need to use a gateway.

u1686_grawity
  • 452,512