2 ethernet interfaces: enp6s18, enp6s19
Need to use enp6s19 as default and use enp6s18 as backup
Principle: set different Metric on different interfaces. The lower Metric is, the higher the priority is.
Need tool nmcli
Run command route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default xiaoqiang 0.0.0.0 UG 101 0 0 enp6s19
default 192.168.1.1 0.0.0.0 UG 105 0 0 enp6s18
10.31.0.0 0.0.0.0 255.255.0.0 U 101 0 0 enp6s19
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 enp6s18
192.168.1.0 0.0.0.0 255.255.255.0 U 105 0 0 enp6s18
Run command nmcli connection show
NAME UUID TYPE DEVICE
use_bridge_pve_to_xiaomi7000 84fcc077-a4ae-4f06-8692-f110c82bc4db ethernet enp6s19
Wired connection 1 3806e4d5-4376-3073-a68d-6e8e376a3f55 ethernet enp6s18
Run command nmcli connection modify "Wired connection 1" ipv4.route-metric 105
Run command nmcli connection modify "use_bridge_pve_to_xiaomi7000 " ipv4.route-metric 101
Note Metric 101 is lower than 105, so the interface whoes name is "use_bridge_pve_to_xiaomi7000" will be prioritized.
In this case traffic go through enp6s19. If enp6s19 fails, traffic will go through enp6s18.
Run command
nmcli connection down "Wired connection 1"
nmcli connection up "Wired connection 1"
nmcli connection down "use_bridge_pve_to_xiaomi7000"
nmcli connection up "use_bridge_pve_to_xiaomi7000"
Run command route