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
Share:
5,597

Related videos on Youtube

comeback4you
Author by

comeback4you

Updated on September 18, 2022

Comments

  • comeback4you
    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 that No 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
      Admin over 8 years
      before we (try to) answer, which combination of route add foo/X ... have you tried ?
    • Admin
      Admin over 8 years
      I have tried ip route add default via 10.10.10.254 dev eth0 and ip 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.