高级网络配置

学习配置网络桥接

学习配置 bond 网络接口

学习配置 team 网络接口







(一)网络桥接


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


一.网络桥接配置文件编写的学习

0.准备
*) [[email protected] ~]# cd /etc/sysconfig/network-scripts/

高级网络配置

*)[[email protected] network-scripts]# mv ifcfg-br0 ifcfg-enp0s25 /mnt


1.[[email protected] network-scripts]# vim ifcfg-enp0s25

高级网络配置


2.[[email protected] network-scripts]# vim ifcfg-br0

高级网络配置


3.测试

*)[[email protected] network-scripts]# systemctl restart network

*)  [[email protected] network-scripts]# brctl show

高级网络配置




二.在虚拟机添加网桥

0.实验前删除所有原有网络配置 保持实验环境纯净

高级网络配置


1.查看网桥
*)[[email protected] network-scripts]# brctl show
高级网络配置


2.添加网桥br0
*)[[email protected] network-scripts]# brctl addbr br0
*)[[email protected] network-scripts]# brctl show
高级网络配置


3.给br0添加ip
*)[[email protected] network-scripts]# ifconfig br0 172.25.254.214 netmask 255.255.255.0
*)[[email protected] network-scripts]# ifconfig
高级网络配置

4.把br0链接到真实网卡上 此时可ping通网络
*)[[email protected] network-scripts]# brctl addif br0 ens3
*)[[email protected] network-scripts]# brctl show

高级网络配置

高级网络配置


5.删除br0
*)[[email protected] network-scripts]# ifconfig br0 down   ##停止br0工作
*)[[email protected] network-scripts]# brctl delif br0 eth0  ##断开br0 和网卡的链接
*)[[email protected] network-scripts]# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.000000000000       no

高级网络配置

*)[[email protected] network-scripts]# brctl delbr br0         ##删除br0
*)[[email protected] network-scripts]# brctl show
bridge name     bridge id               STP enabled     interfaces

高级网络配置







(二)bond 网络

Red Hat Enterprise Linux 允许管理员使用    bonding 内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式 , 通道绑定使两个或更多个网络接口作为一个网络接口 , 从而增加带宽和 / 提供冗余性


0.准备

1.在虚拟化图形管理中给将要实验的虚拟机添加一块虚拟网卡

高级网络配置


高级网络配置


2.nm-connection-editor删除原有配置

3.[[email protected] Desktop]# systemctl status NetworkManager  ##查看状态 应该开启

高级网络配置




一.添加一个bond接口

1.[[email protected] Desktop]# nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.99.12/24  ##添加一个bond接口



2.[[email protected] Desktop]# cat /proc/net/bonding/bond0  ##查看接口内容

高级网络配置



二.监控实验变化

*)[[email protected] Desktop]# watch -n 1 cat /proc/net/bonding/bond0

高级网络配置


三.在bond接口中添加网卡

1.[[email protected] Desktop]# nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0

高级网络配置

高级网络配置


2.[[email protected] Desktop]# nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0

高级网络配置

高级网络配置




四.测试

1.[[email protected] Desktop]# ifconfig eth0 down

高级网络配置

高级网络配置




2.*)[[email protected] Desktop]# ifconfig eth0 up
   *)[[email protected] Desktop]# ifconfig eth1 down

高级网络配置

高级网络配置






(三)Team 接口


Team 和 bond0 功能类似

Team 不需要手动加载相应内核模块

Team 有更强的拓展性    

支持 8 快网卡




0.准备

*)删除所有网络配置 保证实验环境的纯净
    nm-connection-editor

高级网络配置

高级网络配置




一.新建team接口

1.[[email protected] Desktop]# nmcli connection add con-name team0 type team ifname team0 config '{"runner":{"name":"activebackup"}}' ip4 172.25.99.12/24

高级网络配置


2.[[email protected] Desktop]# teamdctl team0 state

高级网络配置



二 .监控

*)[[email protected] Desktop]# watch -n 1  teamdctl team0 state
高级网络配置

 


三.在接口中添加网卡

1.[[email protected] Desktop]# nmcli connection add con-name eth0 ifname  eth0 type team-slave master team0

高级网络配置

高级网络配置

高级网络配置


2.[[email protected] Desktop]# nmcli connection add con-name eth1 ifname  eth1 type team-slave master team0

高级网络配置
高级网络配置




四.测试

1.[[email protected] Desktop]# ifconfig eth0 down
高级网络配置

高级网络配置


2.*)[[email protected] Desktop]# ifconfig eth0 up
   *)[[email protected] Desktop]# ifconfig eth1 down

高级网络配置

高级网络配置