メトリックを使用したネットワークインターフェイスの変更

メトリックを使用したネットワークインターフェイスの変更

eth0とwlan0の間の動的インタフェース変更を実装したいと思います。私が取り組んでいるソリューションの1つは、インターフェイスメトリックを変更することです。とは違うこの問題、私はどんな変更もしたくなかった/etc/networking/interfacesので次を使用しました。ifmetricインターフェース指標を変更します。

$ 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

しかし、このメトリックを効果的に作成する方法、つまりメトリックを反映するようにルーティングテーブルを更新し、wlan0をプライマリインターフェイスにする方法はわかりません。

ベストアンサー1

おすすめ記事