Networking
兩個 NIC 的綁定不起作用/上去
我有一個帶有兩個 NIC 的 Linux 伺服器,它們連接到一個交換機(和一個用於管理的 NIC),我想將它們組合起來並在那裡使用 LACP,但由於某些未知的原因,綁定將無法正常工作/啟動。
它還會忽略 LACP 配置並進入循環模式。
華為交換機配置:
interface Eth-Trunk10 description #### Server #### port link-type trunk port trunk allow-pass vlan 167 stp disable mode lacp load-balance src-dst-mac
/etc/網路/介面:
auto lo iface lo inet loopback iface enp3s0 inet manual auto enp4s0 iface enp4s0 inet manual bond-master bond1 auto eno1 iface eno1 inet manual bond-master bond1 auto bond1 iface bond1 inet manual bond-slaves eno1 enp4s0 bond-miimon 100 bond-mode 802.3ad bond-lacp-rate 1 auto bond1.167 iface bond1.167 inet static address x.x.x.x netmask 255.255.255.248 vlan-raw-device bond1 auto vmbr0 iface vmbr0 inet static address a.a.a.b netmask 255.255.255.248 gateway a.a.a.a bridge-ports enp3s0 bridge-stp off bridge-fd 0
/proc/net/bonding/bond1:
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: load balancing (round-robin) MII Status: down MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: enp4s0 MII Status: down Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 00:1b:21:3a:6f:f9 Slave queue ID: 0 Slave Interface: eno1 MII Status: down Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 00:1b:21:3a:6f:fb Slave queue ID: 0
網路狀態:
● networking.service - Raise network interfaces Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled) Active: active (exited) since Tue 2019-09-24 19:33:18 CEST; 13s ago Docs: man:interfaces(5) Process: 16974 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS) Main PID: 16974 (code=exited, status=0/SUCCESS) Sep 24 19:33:18 rakete systemd[1]: Starting Raise network interfaces... Sep 24 19:33:18 rakete ifup[16974]: /etc/network/if-pre-up.d/ifenslave: 47: echo: echo: I/O error Sep 24 19:33:18 rakete ifup[16974]: /etc/network/if-pre-up.d/ifenslave: 47: echo: echo: I/O error Sep 24 19:33:18 rakete ifup[16974]: Waiting for vmbr0 to get ready (MAXWAIT is 2 seconds). Sep 24 19:33:18 rakete systemd[1]: Started Raise network interfaces.
lsmod | grep 鍵:
bonding 159744 0
我在這些錯誤消息中找不到任何有用的資訊。也許這裡有人對 Linux 中的綁定功能有一些經驗?
更新,ip查找:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master mgmt state UP mode DEFAULT group default qlen 1000 link/ether b4:2e:99:3d:68:64 brd ff:ff:ff:ff:ff:ff 3: enp4s0: <BROADCAST,MULTICAST,SLAVE> mtu 1500 qdisc pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen 1000 link/ether 00:1b:21:3a:6f:f9 brd ff:ff:ff:ff:ff:ff 4: eno1: <BROADCAST,MULTICAST,SLAVE> mtu 1500 qdisc pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen 1000 link/ether 00:1b:21:3a:6f:f9 brd ff:ff:ff:ff:ff:ff 5: bond1: <NO-CARRIER,BROADCAST,MULTICAST,MASTER,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 link/ether 00:1b:21:3a:6f:f9 brd ff:ff:ff:ff:ff:ff 6: bond1.167@bond1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN mode DEFAULT group default qlen 1000 link/ether 00:1b:21:3a:6f:f9 brd ff:ff:ff:ff:ff:ff 7: mgmt: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000 link/ether b4:2e:99:3d:68:64 brd ff:ff:ff:ff:ff:ff
[...] Is bond1.167 ready and a bonding interface ?
答案是否定的,它是一個 VLAN 子介面,它暗示了問題:配置。
您的配置應該定義
bond1
介面,然後是bond1.167
依賴於前者的介面。您試圖使配置短路,導致嘗試在 vlan 介面上應用綁定設置,正如您提供的日誌所示。更新:還有另一個問題:如果enp4s0和eno1的定義在定義之前引用了bond1(參考: with
bond-master bond1
),那麼包 ifenslave 中的配置腳本似乎無法正確處理。在完成了一些測試之後,我可以看到可以選擇以下解決方法之一:
- 從這些介面中刪除auto 。這樣做會啟動實際介面(當配置了bond1時),但ifupdown仍會認為它們在邏輯上沒有啟動。
- 將它們留在開始處,但在介面中不引用bond1(通過刪除
bond-master bond1
)。如果一個物理介面關閉ifdown
然後再次打開,這樣做會在以後破壞綁定配置。- 在bond1定義之後移動它們的定義,保持
bond-master bond1
(並且仍然保持bond-slaves eno1 enp4s0
在bond1定義中)。除了配置順序之外,我看不出這種方法有什麼缺點,所以我最終不得不選擇它。也許ifupdown2可以比原來的ifupdown更好地處理這個問題:
它能夠檢測網路介面依賴關係
甚至使用網路管理器,即使對於伺服器來說可能有點矯枉過正。
請嘗試此配置(更改地址):
auto lo iface lo inet loopback iface enp3s0 inet manual auto bond1 iface bond1 inet manual bond-slaves eno1 enp4s0 bond-miimon 100 bond-mode 802.3ad bond-lacp-rate 1 auto enp4s0 iface enp4s0 inet manual bond-master bond1 auto eno1 iface eno1 inet manual bond-master bond1 auto bond1.167 iface bond1.167 inet static address 192.0.2.2 netmask 255.255.255.248 vlan-raw-device bond1
然後在這裡給出(使用 LXC Debian 10 容器進行測試):
# cat /proc/net/bonding/bond1 Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011) Bonding Mode: IEEE 802.3ad Dynamic link aggregation Transmit Hash Policy: layer2 (0) MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 802.3ad info LACP rate: fast Min links: 0 Aggregator selection policy (ad_select): stable System priority: 65535 System MAC address: 00:1b:21:3a:6f:fb Active Aggregator Info: Aggregator ID: 1 Number of ports: 1 Actor Key: 15 Partner Key: 1 Partner Mac Address: 00:00:00:00:00:00 Slave Interface: eno1 MII Status: up Speed: 10000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:1b:21:3a:6f:fb Slave queue ID: 0 Aggregator ID: 1 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 system mac address: 00:1b:21:3a:6f:fb port key: 15 port priority: 255 port number: 1 port state: 79 details partner lacp pdu: system priority: 65535 system mac address: 00:00:00:00:00:00 oper key: 1 port priority: 255 port number: 1 port state: 1 Slave Interface: enp4s0 MII Status: up Speed: 10000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: 00:1b:21:3a:6f:f9 Slave queue ID: 0 Aggregator ID: 2 Actor Churn State: monitoring Partner Churn State: monitoring Actor Churned Count: 0 Partner Churned Count: 0 details actor lacp pdu: system priority: 65535 system mac address: 00:1b:21:3a:6f:fb port key: 15 port priority: 255 port number: 2 port state: 71 details partner lacp pdu: system priority: 65535 system mac address: 00:00:00:00:00:00 oper key: 1 port priority: 255 port number: 1 port state: 1 # cat /proc/net/vlan/bond1.167 bond1.167 VID: 167 REORDER_HDR: 1 dev->priv_flags: 1021 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 12 total bytes transmitted 976 Device: bond1 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESS priority mappings: