############################
1.用命令建立bond和添加,删除网卡
############################
什么是链路聚合
就是把多个网卡绑定在一起为一个网关工作这就是linux bond
建立一个bond接口配置网关为172.25.254.228
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.228/24
ifconfig查看bond
此时ping不通,原因是没有添加网卡
添加一个eth0
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
把0改为1添加eth1
监控bond0的状态
watch -n 1 cat /proc/net/bonding/bond0
此时监控中能看到两块网卡eth1为备用网卡
ifconifg eth0 down 模拟网卡停止工作
此时eth1会接替工作
ifconfig eth0 up 网卡开始工作,此时eth0为备用网卡
nmcli connection delete eth0 删除网卡
nmcli connection delete bond0 删除bond接口
##############################
2.用文本建立bond
##############################
建立文本
vim /etc/sysconfig/network-scripts/ifcfg-bond0
写下
1 DEVICE=bond0
2 ONBOOT=yes
3 BOOTPROTO=none
4 IPADDR=172.25.254.228
5 NETMASK=255.255.255.0
6 TYPE=Bond
7 BONDING_OPTS=mode=active-backup
建立文本
vim /etc/sysconfig/network-scripts/ifcfg-eth0
写下
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
把以上eth0改为eth1就能添加eth1
#####################
3.用命令建立team和添加网卡
#####################
如图team比bond功能更多
建立team
nmcli connection add con-name team0 ifname team0 type team config ‘{“runner”:{“name”:“activebackup”}}’ ip4 172.25.254.228/24
添加网卡
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
查看team状态
teamdctl team0 stat
和bond一样一个网卡停止工作后另一块会顶替
#################################
4.文本方式建立team
#################################
vim /etc/sysconfig/network-scripts/ifcfg-team0
写下
DEVICE=team0
TEAM_CONFIG="{“runner”:{“name”:“activebackup”}}"
DEVICETYPE=Team
BOOTPROTO=none
IPADDR0=172.25.254.100
PREFIX0=24
NAME=team0
ONBOOT=yes
建立文本
vim /etc/sysconfig/network-scripts/ifcfg-eth0
写下
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
MASTER=team0
把以上eth0改为eth1就能添加eth1
########################
5.桥连接的建立
########################
桥连接就是真机内核出面搭建的连接真机与虚拟机的网络接口的通道
作用是不需要把虚拟机的数据做地址转换再发给真机处理,大大提高运行速度
在/etc/sysconfig/network-scripts/下
配置网卡文件
注意ifconfig查看网卡名称
vim ifcfg-enp2s0
写下
1 BOOTPROTO=none
2 DEVICE=enp2s0
3 ONBOOT=yes
4 BRIDGE=br0
配置桥接文件
vim ifcfg-bro
写下
1 DEVICE=br0
2 ONBOOT=yes
3 BOOTPROTO=none
4 IPADDR=172.25.254.28
5 NETMASK=255.255.255.0
6 TYPE=Bridge
退出保存后记得重读
brctl show 查看
#####################
6.命令的方式建立和删除桥连接
#####################
在虚拟机中
brctl addbr br0 #添加br0
ifconfig bro 172.25.254.128/24 #设置网关
brctl addif br0 eth0 #添加到设备上
brctl show #查看桥连接的状态
ifconfig br0 down #使br0停止工作
brctl delif br0 eth0 #把br0从设备卸载
brctl delbr br0 #删除br0