作者mikukonn (mikukon)
看板Linux
标题[问题] 如何使用iproute2设定bond网路
时间Sat Feb 5 10:08:35 2022
嗨各位大大,我现在有个问题
「如何在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://webptt.com/cn.aspx?n=bbs/Linux/M.1644026920.A.E63.html
1F:→ tjjh89017: 把ip设定到bond上面 02/05 16:22
2F:→ tjjh89017: 用container之後还用bond就很奇怪 02/05 16:22
谢谢您,这个方法的确有用,我想我可能稿错了 bond 的使用方法
我原本是照着文章内的方法将ip设定成 192.0.2.1/24
经过你这麽一说我就将 ip 设定成与 eth0 一样的 10.88.3.7 就可以使用了
十分谢谢您
※ 编辑: mikukonn (103.252.200.83 新加坡), 02/06/2022 07:13:34