Open kingsd041 opened 5 years ago
Setting up multiple default gateways does seem to make no sense.
Judging from the code intent, we want to add multiple default gateways when configuring different routes with multiple network cards. But we have the following error when adding the second default gateway, this error is the cause of the failed addition:
file exists
This error occurs because a default route gateway without metric
property already exists in the routing table, others route gateway can not be added without metric
property.
default via 192.168.1.1 dev eth1 # The root cause
default via 10.0.2.2 dev eth0 src 10.0.2.15 metric 203
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 metric 203
172.30.1.0/24 dev eth2 proto kernel scope link src 172.30.1.100
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100
172.30.1.0/24
network can reachable via eth2
.default via 192.168.1.1 dev eth1 # The root cause
default via 10.0.2.2 dev eth0 src 10.0.2.15 metric 203
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 metric 203
172.30.1.0/24 dev eth2 proto kernel scope link src 172.30.1.100
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100
$ ip route add 172.30.1.0/24 dev eth2
Error occurs: file exists
192.168.1.1
which without metric
property and re-add the default gateway with metric
property:$ route del default gw 192.168.1.1
$ ip route add default via 192.168.1.1 src 192.168.1.100 metric 204
default via 10.0.2.2 dev eth0 src 10.0.2.15 metric 203
default via 192.168.1.1 dev eth1 src 192.168.1.100 metric 204
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 metric 203
172.30.1.0/24 dev eth2 proto kernel scope link src 172.30.1.100
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100
default via 172.30.1.1 dev eth2
default via 10.0.2.2 dev eth0 src 10.0.2.15 metric 203
default via 192.168.1.1 dev eth1 src 192.168.1.100 metric 204
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 metric 203
172.30.1.0/24 dev eth2 proto kernel scope link src 172.30.1.100
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100
RancherOS Version: (ros os version) 1.5.0-rc1 Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.) KVM and virtualbox
My rancheros has multiple NICs, I have set up gateways for
eth1
and 'eth2'. After the setup is successful, I can't find the default gateway of eth2 on rancheros.Expected results
default via 10.31.168.1 dev eth2