高级网络配置

############桥接 Brige   
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

高级网络配置

 4.ip addr show

 5. 桥接到eth0  brctl addif br0 eth0

高级网络配置

 6. 检验是否能连接网络 ping
 7.  brctl delif br0 eth0
 8.ifconfig br0 down
 9. ifconfig
 10. brctl show

 11. brctl delbr br0

高级网络配置

 12. brctl show

 lo 回环接口
 
########bond  网卡阵列 #########

需要两块网卡,一用一备,添加网卡类型为

高级网络配置

 一、虚拟机里添加bond网络连接方式
  1.查看原有连接方式  ifconfig
  2.删除eth0及其配置文件  nmcli connection delete "System eth0"

  3.ifconfig

高级网络配置

  4. sytemctl restart network

高级网络配置 

     ifconnfig 检验是否删除eth0
  5.systemctl start NetworkManager

  6.nmcli connection add con-name bond0 ifname bond0 type bood mode active-backup ip4 172.25.254.120/24

高级网络配置

  7.ifconfig  查看是否创建bond0
  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 监控两个网卡的使用状态

高级网络配置

  10.ping 172.25.254.250 是否连通

  11.若连通,ifdown eth0 卸下eth0(即eth0坏掉了)  注意连通是否中断

高级网络配置

     不中断,证明网卡阵列已搭建好。

  12.把eth0 挂上去  ifup eth0

高级网络配置

  13. nmcli connection delete 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

高级网络配置

  5.创建eth1
   监控team0 状态 watch -n 1 teamdctl team0 stat

  6.若eth0 损坏 eth1顶替   (手动卸载eth0  ## ifconfig eth0 down)

高级网络配置

  7.手动加载 eth0    ifconfig eth0 up

高级网络配置

  8.删除team0 nmcli connection de

高级网络配置

  9.删除eth0 eth1 配置文件