文章插图
一、准备环境
VMware软件、centos7虚拟机
二、添加网卡
为虚拟机再添加两块网卡,查看网卡信息,可以看到有ens32、ens34、ens35三块网卡
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:54:02:06 brd ff:ff:ff:ff:ff:ffinet 192.168.30.142/24 brd 192.168.30.255 scope global noprefixroute dynamic ens32valid_lft 1615sec preferred_lft 1615secinet6 fe80::d089:c15:e69a:8ce4/64 scope link noprefixroutevalid_lft forever preferred_lft forever3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:54:02:1a brd ff:ff:ff:ff:ff:ffinet 192.168.30.143/24 brd 192.168.30.255 scope global noprefixroute dynamic ens34valid_lft 1765sec preferred_lft 1765secinet6 fe80::a4af:b843:9032:9dd3/64 scope link noprefixroutevalid_lft forever preferred_lft forever4: ens35: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:0c:29:54:02:10 brd ff:ff:ff:ff:ff:ffinet 192.168.30.141/24 brd 192.168.30.255 scope global noprefixroute dynamic ens35valid_lft 1765sec preferred_lft 1765secinet6 fe80::b7cf:76d7:23aa:63c2/64 scope link noprefixroutevalid_lft forever preferred_lft forever
查看网卡配置文件,可以看到添加网卡后,并没有生成对应的网卡文件ls
/etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-ens32/etc/sysconfig/network-scripts/ifcfg-lo
可以为网卡生成配置文件,但在本文中不需要这样做nmcli connection add type ethernet con-name ens34 ifname ens34 autoconnect yesnmcli connection add type ethernet con-name ens35 ifname ens35 autoconnect yes
再次查看网卡配置文件,生成成功ls
/etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-ens32/etc/sysconfig/network-scripts/ifcfg-ens35/etc/sysconfig/network-scripts/ifcfg-ens34/etc/sysconfig/network-scripts/ifcfg-lo
三,选定网卡绑定模式多网卡一共有7种bond模式,这里直接选用mode=6 (balance-alb) Adaptive load balancing(适配器适应性负载均衡),该模式不需要交换机支持
四、开始配置
1、加载bonding模块,并设置开机启动
[root@localhost ~]# lsmod | grep bonding[root@localhost ~]# modprobe bonding[root@localhost ~]# lsmod | grep bondingbonding1529790
启用rc.local开机启动项chmod +x /etc/rc.d/rc.local
在文件中写入modprobe bonding
2、建立bond网口配置文件并进行配置
/etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0NAME=bond0TYPE=BondBONDING_MASTER=yesIPADDR=192.168.30.250PREFIX=255.255.255.0GATEWAY=192.168.30.2DNS1=114.114.114.114ONBOOT=yesBOOTPROTO=noneBONDING_OPTS="mode=6miimon=100"
3、修改三块网卡的配置vi
/etc/sysconfig/network-scripts/ifcfg-ens32
DEVICE=ens32ONBOOT=yesBOOTPROTO=noneTYPE=EthernetMASTER=bond0SLAVE=yes
vi /etc/sysconfig/network-scripts/ifcfg-ens34DEVICE=ens34ONBOOT=yesBOOTPROTO=noneTYPE=EthernetMASTER=bond0SLAVE=yes
vi /etc/sysconfig/network-scripts/ifcfg-ens35DEVICE=ens35ONBOOT=yesBOOTPROTO=noneTYPE=EthernetMASTER=bond0SLAVE=yes
4、重新加载网络配置注意:这一步会断网!
【Centos7多网卡绑定bond快速实践】
nmcli connection reload && systemctl restart network.service
使用新IP链接ssh五、验证绑定是否生效
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)Bonding Mode: adaptive load balancingPrimary Slave: NoneCurrently Active Slave: ens32MII Status: upMII Polling Interval (ms): 100Up Delay (ms): 0Down Delay (ms): 0Slave Interface: ens32MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:54:02:06Slave queue ID: 0Slave Interface: ens34MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:54:02:1aSlave queue ID: 0Slave Interface: ens35MII Status: upSpeed: 1000 MbpsDuplex: fullLink Failure Count: 0Permanent HW addr: 00:0c:29:54:02:10Slave queue ID: 0
查看网卡状态ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: ens32: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000link/ether 00:0c:29:54:02:06 brd ff:ff:ff:ff:ff:ff3: ens34: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000link/ether 00:0c:29:54:02:1a brd ff:ff:ff:ff:ff:ff4: ens35: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000link/ether 00:0c:29:54:02:10 brd ff:ff:ff:ff:ff:ff5: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000link/ether 00:0c:29:54:02:06 brd ff:ff:ff:ff:ff:ffinet 192.168.30.250/24 brd 192.168.30.255 scope global bond0valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe54:206/64 scope linkvalid_lft forever preferred_lft forever
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 易武古树茶,古树茶多少钱斤
- 宝宝胳膊脱臼复位后多久能动
- 白百破打完胳膊有硬块
- 明前西湖龙井价格多少钱,为什么都说明前龙井更好
- 明前茶价格,普洱明前茶价格多少钱斤
- 眼霜|别“看不起”国货!赵柯用了多年的眼霜,实力媲美小棕瓶,高质价低太良心
- 淘宝下单太多会不会被降权 淘宝单为什么会降权
- NVIDIA|显卡价格暴跌 RTX 3080 Ti显卡首次跌破8000元:比建议价便宜1000多
- 买的红茶有很多茶梗 红茶女生什么梗
- 抖音店铺保证金退了又想重新开怎么办 抖音保证金退了重新开店要多久