
我正在開發一個將 NetworkManager 優雅地嵌入到其圖像中的平台。有兩個獨立的eth0
、 和eth1
,以及一個 4G 調製解調器,所有這些都工作正常。我們使用NetworkManager來控製網路資源。我們希望優先使用 4G 數據機上的乙太網路連接(即 eth0 和 eth1)。
我們的問題是,3-5 秒後,路由度量從連接中定義的值(即 100)分別更改為 1002 和 1003(對於 1002 和 1003 eth0
)eth1
。但我們希望有一個固定的指標來使用有線連接(如果可用)。
有趣的是,我們的 4G 連線沒有任何問題,因為它的指標保持固定,如連線配置中定義的那樣。
我們已經定義了乙太網路介面所需的所有參數。因此乙太網路連結的連接參數如下:
id=Coolon-ETH0-Connection
uuid=eb6a2892-e1ce-4616-a492-f9b105339070
type=ethernet
autoconnect-priority=9
autoconnect-retries=0
interface-name=eth0
metered=1
multi-connect=3
timestamp=1713921530
[ethernet]
[ipv4]
method=auto
route-metric=100
[ipv6]
addr-gen-mode=stable-privacy
method=auto
route-metric=100
[proxy]
路由表如下:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.247.171.133 0.0.0.0 UG 123 0 0 wwan0
0.0.0.0 192.168.1.1 0.0.0.0 UG 1002 0 0 eth0
10.247.171.128 0.0.0.0 255.255.255.248 U 123 0 0 wwan0
169.254.0.0 0.0.0.0 255.255.0.0 U 3005 0 0 wlan0
192.150.1.0 0.0.0.0 255.255.255.0 U 600 0 0 wlan0
192.168.1.0 0.0.0.0 255.255.255.0 U 1002 0 0 eth0
答案1
正是因為dhcpcd
.當 NetworkManager 嵌入到您的映像中時,只需停用所有 DHCP 服務即可避免衝突。停用dhcpcd
服務後,NetworkManager 根據預先定義的配置優雅地處理所有介面。