[問題] 如何使用iproute2設定bond網路

看板Linux作者 (mikukon)時間2年前 (2022/02/05 10:08), 2年前編輯推噓0(002)
留言2則, 1人參與, 2年前最新討論串1/1
嗨各位大大,我現在有個問題 「如何在Linux中建立bond網路」 我的最終目標是可以建立bond並且讓其可以連上網際網路 我在container中與host都做過了一樣的事情,但是卻得到了一樣的結果 我想使用container可以更容易復現我的結果 1. 環境建立 docker run --cap-add=NET_ADMIN -it ubuntu:20.04 apt update && apt install -y iproute2 2. 建立虛擬網路 # 建立 bond0 網路,並且設定為 backup 模式 ip link add bond0 type bond mode active-backup primary eth0 ip link set eth0 down # 設定 eth0 為 bond0 的子網路 ip link set eth0 master bond0 # 啟動 ip link set eth0 up ip link set bond0 up 3. 測試 # 為了避免dns問題,使用ip更為可靠 curl -vv -H 'Host: www.google.com' 142.251.10.94 我也看過了幾篇網路文章,但是照著操作卻無法連上網路 1. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/configuring-network-bonding_configuring-and-managing-networking 2. http://www.uni-koeln.de/~pbogusze/posts/LACP_configuration_using_iproute2.html 目前在猜測是否需要使用 iptable 去設定封包流 (希望不是) 其他輸出: $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 3: eth0@if10: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc noqueue master bond0 state UP group default link/ether d2:fd:3d:22:8e:7e brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 10.88.3.7/24 brd 10.88.3.255 scope global eth0 valid_lft forever preferred_lft forever 4: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether d2:fd:3d:22:8e:7e brd ff:ff:ff:ff:ff:ff inet6 fe80::d0fd:3dff:fe22:8e7e/64 scope link valid_lft forever preferred_lft forever $ ip route 10.88.3.0/24 dev eth0 proto kernel scope link src 10.88.3.7 $ cat /proc/net/bonding/bond0 Ethernet Channel Bonding Driver: v5.13.0-27-generic Bonding Mode: fault-tolerance (active-backup) Primary Slave: eth0 (primary_reselect always) Currently Active Slave: eth0 MII Status: up MII Polling Interval (ms): 0 Up Delay (ms): 0 Down Delay (ms): 0 Peer Notification Delay (ms): 0 Slave Interface: eth0 MII Status: up Speed: 10000 Mbps Duplex: full Link Failure Count: 0 Permanent HW addr: d2:fd:3d:22:8e:7e Slave queue ID: 0 $ dmesg | grep 'bond0' [238804.742759] bond0: (slave eth0): making interface the new active one [238804.742772] bond0: (slave eth0): Enslaving as an active interface with an up link 如果各位有任何方向還請不吝嗇提出指教 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 103.252.200.83 (新加坡) ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1644026920.A.E63.html

02/05 16:22, 2年前 , 1F
把ip設定到bond上面
02/05 16:22, 1F

02/05 16:22, 2年前 , 2F
用container之後還用bond就很奇怪
02/05 16:22, 2F
謝謝您,這個方法的確有用,我想我可能稿錯了 bond 的使用方法 我原本是照著文章內的方法將ip設定成 192.0.2.1/24 經過你這麼一說我就將 ip 設定成與 eth0 一樣的 10.88.3.7 就可以使用了 十分謝謝您 ※ 編輯: mikukonn (103.252.200.83 新加坡), 02/06/2022 07:13:34
文章代碼(AID): #1X_TmevZ (Linux)