3-unit2 高级网络配置
#######高级网络配置########
学习目标
学习配置网络桥接
学习配置bond网络接口
学习配置team网络接口
***)网络桥接
网络桥接用网络桥实现共享上网主机和客户机除了利用软件外,还可以用系统自带的网络桥建立连接用双网卡的机器做主机
*)网络桥接的配置
vim /etc/sysconfig/network-scripts/ifcfg-eth0
– BRIDGE=br0
vim /etc/sysconfig/network-scripts/ifcfg-br0
– TYPE=Bridge
*)网络桥接的管理命令
brctl ###桥接管理命令
– show ###显示
– addbr ###添加网桥
– delbr ###删除网桥
– addif ###添加网桥连接
– delif ###删除网桥连接
**)bond网络
Red Hat Enterprise Linux 允许管理员使用bonding 内核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定到一个通道。根据选择的绑定模式,通道绑定使两个或更多个网络接口作为一个网络接口,从而增加带宽和 / 提供冗余性
**)选择 Linux 以太网绑定模式
模式 0 (平衡轮循 ) - 轮循策略 ,所有接口都使用采用轮循方式在所有 Slave 中传输封包 ;任何
Slave 都可以接收
模式 1 (主动备份 ) - 容错。一次只能使用一个Slave 接口 ,但是如果该接口出现故障 ,另一个Slave将 接替它
模式 3 (广播 ) - 容错。所有封包都通过所有Slave 接口广播
#####双网卡网络配置######
*链路聚合
*作用:主动备份模式 一次只能只能使用一个接口,如果接口故障,另一个会接替它
命令:nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.162/24 ##添加主动备份模式的bond0,ip为172.25.254.162
命令:watch -n 1 cat /proc/net/bonding/bond0 ##监控网络bond0
命令:nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
##给bond0网络添加eth0网卡
命令:nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
##给bond0网络添加eth1网卡
命令:ifconfig eth1 down ##当网卡eth1故障网卡eth0工作
命令:ifconfig eth1 up ##当网卡eth1启动后网卡eth0还在工作直到eth0故障
命令:ifconfig eth0 down ##当网卡eth0故障切换到网卡eth1工作
############team#########
1.
team也是链路聚合的一种方式
最多支持8块网卡
支持模式
Team的种类
broadcast 广播容错
roundrobin 轮询
activebackup 主备
loadbalance 负载均衡
2.配置
nmcli connection add con-name team0 ifname team0 type team config'{"runner":{"name":"activebackup"}}' ip4172.25.254.136/24 ##添加team0
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 ##添加设备eth0
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 ##添加设备eth1
3.测试:
watch -n 1 teamdctl team0 stat
ifcofig eth0 down ##eth0关闭eth1工作
ifcofig eth0 up ##eth0开启
ifcofig eth1 down ##eth1关闭eth0工作
##############网桥#####
1.配置
vim /etc/sysconfig/network-scripts/ifcfg-enp0s25
DEVICE=enp0s25 ##设备名称
ONBOOT=yes ##开启服务设备自动**
BOOTPROTO=none ##网卡工作状态
BRIDGE=br0 ##网卡开启的网桥接口
vim /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.36
NETMASK=255.255.255.0
TYPE=Bridge ##网络接口类型是桥接
systemctl stop NetworkManager.service
systemctl restart network
systemctl start NetworkManager.service
##命令:ifconfig ##查看网络
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.25.254.62 netmask 255.255.255.0 broadcast 172.25.254.255
inet6fe80::221:ccff:fe60:32a3 prefixlen64 scopeid 0x20<link>
ether 00:21:cc:60:32:a3 txqueuelen 0 (Ethernet)
RX packets 25396 bytes 59291358 (56.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 15360 bytes 105128915 (100.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
##########命令管理方式
##添加
systemctl start NetworkManager
brctl show ##查看br配置
brctl addbr br0 ##添加br0
brctl addif br0 eth0 ##给br0添加网卡eth0
ifconfig eth0 up ##启动网卡eth0
ifconfig br0 172.25.254.136 netmask 255.255.255.0 ##配置网络
brctl show
ping 172.25.254.250
##删除
ifconfig br0 down ##br0关闭
brctl delif br0 eth0 ##删除br0上的网卡eth0
brctl delbr br0 ##删除br0
brctl show
本文转自cuijb0221 51CTO博客,原文链接:http://blog.51cto.com/cuijb/1926832