如何使用iproute2設定bond網路 - Linux
By Isabella
at 2022-02-05T10:08
at 2022-02-05T10:08
Table of Contents
嗨各位大大,我現在有個問題
「如何在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
如果各位有任何方向還請不吝嗇提出指教
謝謝
--
「如何在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
如果各位有任何方向還請不吝嗇提出指教
謝謝
--
Tags:
Linux
All Comments
By Yedda
at 2022-02-05T12:35
at 2022-02-05T12:35
Related Posts
Slackware 15.0
By Quanna
at 2022-02-04T21:55
at 2022-02-04T21:55
Linux 友好點的中文語音嘛?
By Necoo
at 2022-02-02T12:12
at 2022-02-02T12:12
請問 ssh 連線是否有時間限制?
By Tracy
at 2022-02-01T22:01
at 2022-02-01T22:01
在Surface 3 上試著安裝上Ubuntu…………
By Ingrid
at 2022-02-01T20:10
at 2022-02-01T20:10
背景執行並隱藏輸出問題
By James
at 2022-01-31T21:36
at 2022-01-31T21:36