一.网络桥接
     网络桥接用网络桥实现共享上网主机和客户机除了利用软件外 ,
     还可以用系统自带的网络桥建立连接用双网卡的机器做主机。

1.用NAT网络模式安装虚拟机

发现安装过程速度很慢

2.网络桥接的配置
实验之前先 mv /etc/sysconfig/network-sctipts/ifcfg-br0 /mnt/    mv /etc/sysconfig/network-sctipts/ifcfg-br0 /mnt/  避免出现冲突
          nm-connection-editor  删除里面所有的网络   
配置网桥参数文件
vim /etc/sysconfig/network-scripts/ifcfg-eth0      enp0s25是主机的物理网卡
BOOTPROTO=none                        
IPADDR=172.25.254.24      
NAME=eth0    
DEVICE=enp0s25
BRIDGE=br0                                    网卡开启网桥接口

vim /etc/sysconfig/network-scripts/ifcfg-br0   桥接配置文件
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.24
NETMASK=255.255.255.0
TYPE=Bridge                  工作模式为桥接

systemctl stop NetworkManager.service     关闭网络管理工具不让系统记录网络
systemctl restart network                 重启网络服务
systemctl start NetworkManager.service    开启网络管理工具

3.选择桥接网络模式安装虚拟机,测试安装速度

4.网桥设置
brctl show          查看网桥

brctl addbr br0     添加网桥br0

ifconfig br0 172.25.254.124 netmask 255.255.255.0 设定br0的ip为172.25.254.124,子网掩码为255.255.255.0

brctl  addif  br0  eth0       将虚拟网卡br0插到真实网卡eth0上

ifconfig br0 down  关闭网桥()

brctl delif br0 eth0  将虚拟网卡从真实网卡eth0上拔除

brctl delbr br0    删除网桥

二:bond网络
1.Red Hat Enterprise Linux 允许管理员使用 bonding 内
  核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定
  到一个通道。根据选择的绑定模式 , 通道绑定使两个或更多个
  网络接口作为一个网络接口 , 从而增加带宽和 / 提供冗余性 。
 
2.绑定模式
  模式 0 ( 平衡轮循 ) - 轮循策略 , 所有接口都使用采用轮循
  方式在所有 Slave 中传输封包 ; 任何 Slave 都可以接收
  模式 1 ( 主动备份 ) - 容错。一次只能使用一个 Slave 接口
  ,但是如果该接口出现故障 , 另一个 Slave 将 接替它   
  模式 3 ( 广播 ) - 容错。所有封包都通过所有 Slave 接口广
  播

实验(以模式1为例):
1.首先在虚拟机中添加一块新的网卡eth1
2.添加模式主动备份的bond bond,并配ip   nmcli connection add type bond ifname bond0 mode active-backup ip4 172.25.254.124/24
     ifconfig可以查看到bond0

wKiom1mPJbGB41QCAACRpyhWkSA895.png3.给bond0添加接口eth0,打开监控bond0接口状态和网络状态,连接eth0后,eth0已工作,网络通
  nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
  watch -n 1 cat /proc/net/bonding/bond0
  ping 172.25.254.250
4.给bond0添加接口eth1,从监控可以看到eth1已经进入备用模式, ifconfig eth0 down,破坏掉eth0,从监控可以看到eth1接替工作,网络不断



5.删除eth0,更换新网卡
  nmcli connection delete eth0
  nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0

wKiom1mPJi6xvuEmAACLzmKMlak598.png

wKioL1mPJi_x0U8yAAGUUATWQ1w311.png


wKioL1mPJorBAcD1AAJcnOVaP6s065.png


6.删除bond,删除eth0,删除eth1
  nmcli connection delete bond-bond0
  nmcli connection delete eth0
  nmcli connection delete eth1

wKiom1mPJqeS2XVaAAHk4tyFSn8305.png




三.team链路聚合
 1.Team和bond0功能类似,team不需要手动家在相应内核模块,它有更强的拓展性,支持8块网卡。
 
 2.team的种类:broadcast  广播容错  roundrobin  平衡轮叫     activebackup 主备       loadbalance 负载均衡

实验:
   1.添加模式为主动备份的team team0,并配置IP
   nmcli connection add type team ifname team0 config '{"runner":{"name":"activevackup"}}' ip4 172.25.254.124/24
   

wKioL1mPJvbRdrAIAAA8Fgl3hus006.png

wKiom1mPJvfA9b8UAAEa0zeIZjU506.png


    watch -n 1 teamdctl team0 state    监控team0的状态
    ping  172.25.254.250    测试网络状态
   2.将接口eth0,eth1添加到team0中,从监控中可以看到两块网卡的工作状态,网络连通
     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
   3.ifconfig eth0 down   破坏eth0,从监控可以看到eth1接替工作,网络不断

    wKioL1mPJx2j1gogAAB-b1B2Qug130.png


   4.删除team0,eth0,eth1
     nmcli connection delete team-team0
     nmcli connection delete eth0
    nmcli connection delete eth1

wKioL1mPJzGwNJRSAABxA1YQebs296.png