add route in Linux if sub-net, where gateway is situated, is not configured
5,597
Try this:
ip route add 172.16.0.1/32 via 10.10.10.254 dev eth0 onlink
Related videos on Youtube
Author by
comeback4you
Updated on September 18, 2022Comments
-
comeback4you over 1 year
I have a PC which has 192.168.1.1/24 configured to eth0 interface. Now if I try to add routes via 10.10.10.254, the
ip
utility reports thatNo such process
:root@PC:~# ip neigh add 10.10.10.254 lladdr 00:01:02:03:04:05 dev eth0 root@PC:~# ip route add default via 10.10.10.254 dev eth0 RTNETLINK answers: No such process root@PC:~# ip route add 172.16.0.1/32 via 10.10.10.254 dev eth0 RTNETLINK answers: No such process root@PC:~#
As long as PC knows the MAC address of 10.10.10.254 it is technically possible to send data via 10.10.10.254 while 10/8 network is not configured to any interface in PC. Based on my example it would use PCs eth0 MAC address as a source MAC, 00:01:02:03:04:05 as a destination MAC, 192.168.1.1 as a source IP address and destination address would be whatever I specify.
Is it possible to force Linux to add a route if sub-net, where gateway is situated, is not in configured to an interface?
-
Admin over 8 yearsbefore we (try to) answer, which combination of
route add foo/X ...
have you tried ? -
Admin over 8 yearsI have tried
ip route add default via 10.10.10.254 dev eth0
andip route add 172.16.0.1/32 via 10.10.10.254 dev eth0
. However, the point does not seem to be which destination network I use, but the fact that eth0 interface does not have address from the same broadcast domain that 10.10.10.254.
-