
我最近在具有 2 個乙太網路連接埠的虛擬機器上安裝了 Ubuntu 20.04。我正在嘗試綁定這兩個以太網端口,但找不到正確的方法。例如,有人說沒有netplan,其他人說有netplan,bond withbridge等。
我是新手,有沒有辦法進行簡單的黏合?
更新:我達到了這一點:
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: false
eth2:
dhcp4: false
bonds:
bond0:
dhcp4: false
interfaces:
- eth1
- eth2
parameters:
mode: balance-rr
mii-monitor-interval: 100
bridges:
br0:
dhcp4: true
interfaces:
- bond0
而且我無法取得 的 IP br0
。如果我只使用bond0
without ,也會發生同樣的情況br0
。
謝謝
答案1
正如您的螢幕截圖所示,您有三個乙太網路:eth0, eth1, eth2
。eth0
有一個IP,所以你有一些配置(即透過ifupdown
設定/etc/network/interfaces
)。
我希望eth1, eth2
沒有連接到相同的交換器和網絡,要使其正常工作,需要更多設置。
您應該檢查是否有任何其他工具ifupdown
未用於啟動eth1, eth2
和bond0
, br0
。
請勿將此工具與 netplan 一起使用。停用eth1, eth2
ifaces – 刪除帶有auto
for 的行eth1, eth2
,僅新增一行:iface eth1 inet manual
對於每一行。或重新命名或刪除檔案/etc/network/interfaces
。
如果您重新命名或刪除/etc/network/interfaces
,您應該將設定新增eth0
至 netplan config。
例如,在我的配置中我有em1, em2
乙太網路。bond0
它在一起,並且br0
位於 的頂部bond0
。br0
透過 DHCP 獲取 IP。br0
需要從該伺服器上的虛擬機器存取網路。我的配置:
network:
version: 2
renderer: networkd
ethernets:
em1:
dhcp4: no
dhcp6: no
em2:
dhcp4: no
dhcp6: no
bonds:
bond0:
dhcp4: no
dhcp6: no
interfaces:
- em1
- em2
macaddress: "xx:xx:xx:xx:2b:62"
parameters:
mode: 802.3ad
lacp-rate: fast
mii-monitor-interval: 100
transmit-hash-policy: layer2+3
bridges:
br0:
dhcp4: yes
dhcp6: yes
macaddress: "xx:xx:xx:xx:2b:62"
interfaces:
- bond0
您可以使用 刪除部分bridges
並將其設定dhcp4: yes, dhcp6: yes
為bond0
。這應該也可以工作,並且bond0
應該從 DHCP 獲取 IP。
我還做了一個工作配置ifupdown2
(也許是因為舊版本ifupdown
無法處理 ifaces 依賴項,但ifupdown2
可以)。
答案2
根據你和我自己的配置,我想像這樣的東西可以工作:
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: false
eth2:
dhcp4: false
bonds:
bond0:
dhcp4: false
interfaces:
- eth1
- eth2
parameters:
mode: balance-rr
mii-monitor-interval: 100
bridges:
br0:
dhcp4: true
gateway4: your.gate.way.addr
interfaces:
- bond0