1.网卡的bond
bond网络
red hat Enterprise Linux 容许管理员使用bonding内核模块和称为通道绑定接口的特殊网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多个网络接口做为一个网络接口,从而增长宽带/提供冗余性
选择Linux以太网绑定模式(前两种为经常使用模式)
1)模式0平衡轮循 同时
2)模式1主动备份 稳定
3)模式3广播容错web
2.配置bond网络接口
添加两个网卡eth0和eth1
添加eth1网卡vim
nm-connection-editor #delete 删除eth0的ip
ifconfig #查看网卡信息
网络
nmcli connection show #查看网络链接信息 nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.114/24 #添加bond网络接口bond0 ifconfig #查看是否将bond接口添加成功
watch -n 1 cat /proc/net/bonding/bond0 #监控bond接
口svg
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 #把网卡eth0添加到bond0中
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 #把网卡eth1添加到bond0中
测试:测试
ping 172.25.254.14能够ping通 ifconfig eth0 down #也能够ping通
看见eth0处于down状态,而以前ping的并未中止
3d
ifconfig eth0 up #使eth0恢复,此时使用的是eth1,而eth0处于闲置
删除bond接口:rest
nmcli connection delete bond0 #删除bond接口 nmcli connection show #查看网络接口信息
nmcli connection delete eth0 #删除eth0与band0的链接
nmcli connection delete eth1 #删除eth1与band0的链接
nmcli connection show #再次查看网络接口信息
3.配置team网络接口code
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.114/24 #添加team网络接口
ifconfig #查看是否添加成功
watch -n 1 teamdctl team0 stat #监控team0 nmcli connection add con-name eth0 ifname eth0 type team-slave master tam0 #添加eth0到team接口
nmcli connection add con-name eth1 ifname eth1 type team-slave master tam0 #添加eth1到team接口
测试:xml
ping 172.25.254.14 #能够ping通 ,使用的是eth0
ifconfig eth0 down #关闭eth0,还能够ping通,使用的是eth1
4.桥接br0的做用
在真机中切换到root用户
未使用br0时:blog
cd /etc/sysconfig/network-script/ ls
cp ifcfg-br0 ifcfg-enp0s25 /mnt/ #备份ifcfg-br0,ifcfg-enp0s25两个文件到mnt下
nm-connection-editor #清空全部的网络信息,其中有的删除不了
add从新添加一个网络westos(名字自拟)
virt-manager
新建一个虚拟机,选择第二个Network Install
填写URL地址
RAM和CPU默认
最后Network selection选择NAT
安装
点击Send Key选择f2到无图形界面
ifconfig能够查看到此虚拟机的网络地址为192.168.122.188(和真机不在一个网段)
此时ping172.24.254.13(速度慢)
使用br0时:
关闭此虚拟机,回到真机
ifconfig #查看真机网络名称,看到什么用什么
切换到超级用户
cd /etc/sysconfig/network-script/
vim ifcfg-westos
修改网络配置信息
vim ifcfg-br0
新建添加网络配置信息
systemctl stop NetworkManager systemctl restart network #重启网络服务 ifconfig #再次查看会发现出现了br0
brctl show #显示br0在真实物理硬件enp0s25上
删除刚才新建的虚拟机
再次新建一个虚拟机
选择第二个Network Install
填写URL地址
RAM和CPU默认
最后Network selection选择Bridge br0:Host device enp0s25
安装
点击Send Key选择f2到无图形界面
ifconfig能够查看到此虚拟机的网络地址为172.25.254.86(和真机在一个网段)
此时ping172.25.254.13 (速度快)
删除桥接:
rm -rf ifcfg-westos #删除本身配置的网络 rm -rf ifcfg-br0 #删除 cp /mnt/ifcfg-* . #恢复以前的备份到当前文件夹
reboot
6.桥接接口
先删除team0
临时添加桥接br0:
brctl show #显示桥接及其链接的真实物理设备
brctl addbr br0 #添加桥接 brctl show #显示桥接及其链接的真实物理设备,此时可看见添加的br0 ifconfig #能够看见br0
ifconfig br0 172.25.254.114/24 #临时添加ip ifconfig #查看br0上的ip为172.25.254.114
ping 172.25.254.13 #此时并不能够ping通
brctl show #看见br0并不在真实物理设备eth0上
brctl addif br0 eth0 #添加br0到真实物理设备eth0上 brctl show #再次查看正确
ping 172.25.254.13 #能够ping通
reboot以后就没有了
删除桥接br0:
brctl show #查看br0信息
brctl delif br0 eth0 #从eth0物理设备上删除br0 brctl show #br0已经不在eth0上
ifconfig bro down #把br0关闭 ifconfig #查看br0状态
brctl show #查看br0
brctl delbr br0 #删除桥接br0
brctl show #查看桥接
ifconfig #查看已经没有br0
临时设置ip: ifconfig enp0s25 172.25.254.14/24