1

I want to achieve dynamic interface change between eth0 and wlan0, one solution I am looking into is to change interface metric. Different than this question, I don't want to make any change to /etc/networking/interfaces, so I used ifmetricto change interface metrics.

$ netstat -ren
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     1000   0        0 wlan0
$ sudo ifmetric eth0 1000
$ sudo ifmetric wlan0 0
$ netstat -ren
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    1000   0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0
192.168.1.0     0.0.0.0         255.255.255.0   U     1000   0        0 eth0

But I don't know how to put this metric to effect, i.e. how to refresh the routing table to reflect metric and let wlan0 become the primary interface?

Lingyuan He
  • 23
  • 1
  • 5

0 Answers0