本文摘抄自 https://www.cnblogs.com/liwanggui/p/6807212.html
centos7网卡bond配置
centos7网卡bond配置
1 备份网卡配置文件
2 使用nmcli命令配置bond
3 修改bond0网卡配置
4 重启网络,验证配置结果
5 删除 bond 设备
6 ifensalve 工具
实验环境
[root@localhost ~]# cat /etc/redhat-release CentOSLinux release 7.2.1511(Core) [root@localhost ~]# uname -r 3.10.0-327.el7.x86_64
linux服务器 eno33554960
与 eno50332184
两张网卡配置 bond 步骤(如果要配置多个bond0,1…按照这个流程重复操作即可)参考
查看网卡信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
1 备份网卡配置文件
1 2 3 4 5 |
|
2 使用nmcli命令配置bond
1 2 3 4 5 6 7 8 |
|
bond的mode如下:
- balance-rr (0) –轮询模式,负载均衡(bond默认的模式)
- active-backup (1) –主备模式(常用)
- balance-xor (2)
- broadcast (3)
- 802.3ad (4) –聚合模式
- balance-tlb (5)
- balance-alb (6)
3 修改bond0网卡配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Tips: 如果不想修改
bond
网络接口配置文件可以在第2步
的第一条命令后加上ip4 "ip地址" gw4 "网关地址"
nmcli connection add type bond ifname bond0 mode 1 ip4 192.168.92.20/24 gw4 192.168.92.2
4 重启网络,验证配置结果
1. 查看网卡信息
[root@localhost network-scripts]# ip addr show 1: lo:<LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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 2: eno16777736:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:07:2c:86 brd ff:ff:ff:ff:ff:ff inet 192.168.92.11/24 brd 192.168.92.255 scope global eno16777736 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe07:2c86/64 scope link valid_lft forever preferred_lft forever 3: eno33554960:<BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000 link/ether 00:0c:29:07:2c:90 brd ff:ff:ff:ff:ff:ff 4: eno50332184:<BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP qlen 1000 link/ether 00:0c:29:07:2c:90 brd ff:ff:ff:ff:ff:ff 31: bond0:<BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP link/ether 00:0c:29:07:2c:90 brd ff:ff:ff:ff:ff:ff inet 192.168.92.20/24 brd 192.168.92.255 scope global bond0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe07:2c90/64 scope link valid_lft forever preferred_lft forever
2. 查看bond信息
[root@localhost network-scripts]# cat /proc/net/bonding/bond0 EthernetChannelBondingDriver: v3.7.1(April27,2011) BondingMode: fault-tolerance (active-backup)===> bond主备模式 PrimarySlave:None CurrentlyActiveSlave: eno33554960 ===>当前激活的网卡eno33554960 MII Status: up MII PollingInterval(ms):100 UpDelay(ms):0 DownDelay(ms):0 SlaveInterface: eno33554960 ===> bond0 组内的网卡 MII Status: up Speed:1000Mbps Duplex: full LinkFailureCount:0 Permanent HW addr:00:0c:29:07:2c:90 Slave queue ID:0 SlaveInterface: eno50332184 ===> bond0 组内的网卡 MII Status: up Speed:1000Mbps Duplex: full LinkFailureCount:0 Permanent HW addr:00:0c:29:07:2c:9a Slave queue ID:0
5 删除 bond 设备
当我们需要删除bond
设备的时候,该如何删除呢?请看下面操作
1.查看网络设备
[root@localhost ~]# ls /sys/class/net/ bond0 bond1 bonding_masters eno16777736 eno33554960 eno50332184 eno67109408 eno83886632 lo
2.删除bond网络设备
直接删除bond0,会提示无权限。
可以通过bonding_masters文件删除bond设备,但是bonding_masters文件是无法直接修改的。
[root@localhost ~]# echo -bond0 >/sys/class/net/bonding_masters
echo 后面的 ‘-’ 是删除设备,‘+’是增加设备