高级网络配置
team 和 bonding
/etc/sysconfig/network-scripts/
一、在真机
mv ifcfg-br0 ifcfg-enp0s25 /mnt ##copy##
vim ifcfg-enp0s25
原来的配置文件
[[email protected] network-scripts]# cat ifcfg-enp0s25
DEVICE=enp0s25
BOOTPROTO=none
BRIDGE=br0
ONBOOT=yes
TYPE=Ethernet
NAME="System enp0s25"
修改后的:
[[email protected] network-scripts]# cat ifcfg-enp0s25
DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
搭桥 vim ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.20
NETMASK=255.255.255.0
TYPE=Bridge
还原网络
删除新建的 ifcfg-enp0s25 ifcfg-br0
还原到原来位置 mv /mnt/ifcfg-* .
二、在虚拟机
1.brctl show 查看有无br0
2.新建br0 brctl addbr br0 不能连接到网
3.添加ip ifconfig br0 17225.254.100/24
5. 桥接到eth0 brctl addif br0 eth0
7. brctl delif br0 eth0
8.ifconfig br0 down
9. ifconfig
10. brctl show
11. brctl delbr br0
lo 回环接口
########bond 网卡阵列 #########
需要两块网卡,一用一备,添加网卡类型为
1.查看原有连接方式 ifconfig
2.删除eth0及其配置文件 nmcli connection delete "System eth0"
3.ifconfig
4. sytemctl restart network
5.systemctl start NetworkManager
6.nmcli connection add con-name bond0 ifname bond0 type bood mode active-backup ip4 172.25.254.120/24
8.nmcli conection add con-name eth0 ifname eth0 type bond-slave master bond0 在网卡阵列中加入eth0
9.nmcli conection add con-name eth1 ifname eth1 type bond-slave master bond0 在网卡阵列中加入eth1
#### watch -n 1 cat /proc/net/bonding/bond0 监控两个网卡的使用状态
11.若连通,ifdown eth0 卸下eth0(即eth0坏掉了) 注意连通是否中断
12.把eth0 挂上去 ifup eth0
14. nmcli connection delete eth1
15. nmcli connection delete bond0
###主动备份配置文件示例###
如图:
二、team
team和bond0功能类似
team 不需要手动加载相应内核模块
team 有更强的拓展性 最多支持 8块 网卡
(1)种类
##roundrobin 平衡轮叫 (谁有空闲找谁)
##loadbalance 负载均衡
##broadcast 广播容错
##activebackup 主备
(2)创建步骤
1.删除bond0 eth0 eth1
2.查看是否删除 ifconfig
3.创建team
nmcli connection add type team con-name team0 ifname team0 config
##config team的类型
##如有需要,重启网络
4.创建eth0
监控team0 状态 watch -n 1 teamdctl team0 stat
6.若eth0 损坏 eth1顶替 (手动卸载eth0 ## ifconfig eth0 down)
7.手动加载 eth0 ifconfig eth0 up
8.删除team0 nmcli connection de