by summers » Sun Nov 22, 2020 8:56 am
Not quite clear exactly what you are asking, becuase its not totally clear what your network is. Its usual though when a network connection is brought up, and an IP address is set that if a broadcast gets a reply that the route of the nearest neighbor gets added. This happens for me as part of the network interface configuration, so its quite early and before any default route gets set. So if I take a very simple example, the route on my pocket beagle, that *only* has a usb ethernet port on the usb otg port:
$this->bbcode_second_pass_code('', 'default via 192.168.7.17 dev usb0 proto static
192.168.7.16/30 dev usb0 proto kernel scope link src 192.168.7.18 ')
So the 192.168.7.16/30 was set when the interface was brought up, this was done by systemd-networkd via the script, /etc/systemd/networkd/usb0.network:
$this->bbcode_second_pass_code('', '[Match]
Name=usb0
[Network]
DNS=192.168.2.1
DHCPServer=true
[Address]
Address=192.168.7.18/30
[Route]
Gateway=192.168.7.17
[DHCPServer]
EmitDNS=false
EmitNTP=false
EmitSIP=false
EmitRouter=false
')
So can see how the usb otg device has been set up to be a very limited /30 address. Also how the default gateway is on 192.168.7.17 - which is conveniently in the /30 address range. Now when that default route is set up, route checks the routing and sees where to send those packets. In this case it out 192.168.7.17 that the rest of the routing says goes via usb0. So you can see both lines in routing are needed, kinda conceptually - one when the interface comes up, and one when default routing gets set.
A more complex example is on my router, running openwrt:
$this->bbcode_second_pass_code('', 'default via 195.166.130.255 dev pppoa-wan
192.168.2.0/24 dev br-lan scope link src 192.168.2.1
192.168.7.0/24 via 192.168.2.144 dev br-lan
195.166.130.255 dev pppoa-wan scope link src 87.112.62.10
')
There two directly connected interfaces are brought up 192.168.2.0/24 - which is the local LAN, a gang of four ethernet ports, and also the wifi lives under 192.168.2.0/24 - thing to note is how its tied to the br-lan device which descibes that hardware.
The second directly connected route is 195.166.130.255, which goes out across a network connection on the ADSL line. This is the WAN.
The default route when it came to added is sent via the WAN, and although that will have been set via the ip number, when added to the route table, the device is added - to make that routing easier. SO all default traffic goes on the ppoa-wan device to the gateway 195.166.130.255.
Finally note the 192.168.7.0/24 route, odd in that it doesn't go via a physical device, but it sent to the 192.168.2.144 machine (on the br-lan). That machine is actually my NAS, and its has my beagle farm plugged into its usb ports. So this means my router knows about where my beagle farm lives, and as my router is the default route for my LAN, its where all traffic goes. This means that my LAN knows about the beagle network - so I can log into the beagle farm from anywhere on the LAN.
Now as far as I can see, your set up is doing just the same, setting the interface route up separately from the default gateway. And this is good.