I have 2 network cards on my linux pc, and with next route settings:
$ ip route
default via 10.192.244.254 dev enp0s31f6 proto static metric 100
default via 192.168.100.1 dev enp2s0 proto dhcp src 192.168.100.106 metric 200
10.192.244.0/24 dev enp0s31f6 proto kernel scope link src 10.192.244.193
169.254.0.0/16 dev docker0 scope link metric 1000
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.100.0/23 dev enp2s0 proto kernel scope link src 192.168.100.106
192.168.100.1 dev enp2s0 proto dhcp scope link src 192.168.100.106 metric 200
In Metrics (networking), it said:
Router metrics are metrics used by a router to make routing decisions. A metric is typically one of many fields in a routing table. Router metrics help the router choose the best route among multiple feasible routes to a destination. The route will go in the direction of the gateway with the lowest metric.
So, I think the gateway 10.192.244.254
has high priority. But, with next python code:
try.py:
import netifaces
gateways = netifaces.gateways()
print(gateways)
execution:
$ python3 try.py
{'default': {2: ('192.168.100.1', 'enp2s0')}, 2: [('10.192.244.254', 'enp0s31f6', True), ('192.168.100.1', 'enp2s0', True)]}
You can see it just tell me 192.168.100.1
is the default router, why it not choose 10.192.244.254
or show me 2 default routers?