大网数据广告活动
服务器运维问答

Change an active slave of Linux network bonding interface without ifenslave command

· 52CE 我爱测

Linux supports bonding of multiple Ethernet network interfaces for extra reliability or load balancing. Bonding driver used to be configured via ifenslave command, which has been deprecated (superseded by ip command from iproute2…

问题原文

原帖链接 · Mikhail Kupchik · CC BY-SA 4.0

Linux supports bonding of multiple Ethernet network interfaces for extra reliability or load balancing.

Bonding driver used to be configured via ifenslave command, which has been deprecated (superseded by ip command from iproute2 toolkit), so ifenslave was removed from the kernel sources.

One particular feature of deprecated command which I can't find a modern equivalent for is changing an active slave of the bonding interface (assuming that bonding interface is operating in the active-backup mode).

For example, the following commands set eth0 network card as an active slave of bond0 interface:

ifenslave -c bond0 eth0
ifenslave --change-active bond0 eth0

Is there a way to change an active slave of Linux bonding interface using ip command from the iproute2 toolkit or, alternatively, via sysfs?

已采纳解答

原帖链接 · Anton Danilov · CC BY-SA 4.0

Create procedure for bonding interface:

# create the bonding interface with active-backup mode
ip link add name bond0 type bond mode active-backup

# add the under laying interfaces
# the interface, that has been added first, will be active
ip link set master bond0 dev eth1
ip link set master bond0 dev eth0

# enable the bonding interface
ip link set up dev bond0
ip address add 192.168.100.1/24 dev bond0

# check the results: detailed info and statistics of bond0
ip -s -s -d link ls dev bond0

# check the state of ALL under laying interfaces
# with statistics and details 
ip -s -s -d link ls master bond0

# check the kernel logs
journalctl -kn 20

To change the active link for bonding device you should use this command:

ip link set dev bond0 type bond active_slave eth0

If you have gotten the error like RTNETLINK answers: invalid argument then check the dmesg or the journalctl -k outputs.

For brief help for options you can use ip link add type bond help command. It applies to any link type.

All values of current options of bond0 interface you can get with ip -d l ls dev bond0 command.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-05-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。