高级网络管理
一. Bonding模式
Bond就是把两块网卡绑在一起工作,当其中一块坏掉另一块顶替工作,保证网路的通畅
1.链路聚合,两块网卡,当其中一块坏掉另一块顶替工作,保证网路的通畅
2.虚拟机两块网卡,eth0,eth1.
3.nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.110/24
4.nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 添加eth0到bond0中
5.nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 添加eth1到bond0中
6.新开shell watch -n 1 cat /proc/net/bonding/bond0 ##监控bond0的状态
7. ifconfig eth0 down
ifconfig eth0 up
ifconfig eth1 down
实验:
1.Desktop虚拟机准备两块虚拟网卡eth0,eth1
2.nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip 172.25.254.110/24 ##制作bond模式网卡,命名bond0,当其中一块坏掉另一块顶替工作,保证网路的通畅,模式为主动式备用工作方式,设ip为172.25.254.110
3.
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中
测试:ifconfig eth0 down down掉eth0网卡,网络依然通常
ifconfig eth0 down; ifconfig eth1 同时down掉两块网卡,网络故障
二.Team模式
企业7有,企业6没有,最多支持8快网卡
1.准备两块网卡
2.nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’ ip4 172.25.254.110/24
3.ifconfig 查看team信息
4.nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
5.nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
6.watch -n 1 “teamdctl team0 state ” 监控team0信息
7.ifconfig eth0 down
ifconfig eth1 down
实验:ifconfig connection delete bond0 删除bond0,还源实验环境
1.nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”:{“name”:”activebackup”}}’ ip4 172.25.254.110/24 制作team类型网卡team0,模式为主动式备用式,ip4设为172.25.254.110
2.nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
添加eth0,eth1两块网卡到team0中
3.ifconfig eth0 down
ifconfig eth1 down
##四.桥接
桥接
1.
vim /etc/sysconfig/network-scripts/ifcfg-enps0s25
cat ifcfg-enps0s25
DEVICE=enp0s25
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
vim /etc/sysconfig/network-scripts/ifcfg-enps0s25
cat ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
TYPE=Bridge
IPADDR=172.25.254.10
PREFIX=24
2.命令模式管理
桥接命令模式;
ifconfig 查看是否有桥br0
brctl addbr br0 添加桥br0
brctl show 查看桥接状态
ifconfig br0 172.25.254.110 netmask 255.255.255.0 设定桥的ip和子网掩码
ping 172.25.254.250 ping 不通
brctl addif br0 eth0 桥接br0网卡到eth0
brctl show 查看桥接状态
ping 172.25.254.250 ping通
brctl delif br0 eth0 取消br0桥接到eth0
brctl show 查看桥接状态
brctl delbr br0
ifconfig br0 down down掉br0
brctl delbr br0 删除br0
brctl show 查看桥接状态
实验:
Ifconfig查看到桥接br0
Ping 不通还没添加网卡
brctl addif br0 eth0 桥接br0网卡到eth0