天天看点

linux--高级网络配置 bond team br0

桥接(Bridging),是指依据OSI网络模型的链路层的地址,对网络数据包装进行转发的过程。

通过网桥可以把两个不同的物理局域网连接起来,是一种在链路层实现局域网互连的存储转发

设备。通俗的说就是通过一台设备(可能不知一个)把几个网络串联起来形成的连接,以延长

和增大网络长度及规模。

Red Hat Enterprise Linux 允许管理员使用 bonding 内

核模块和称为通道绑定接口的特殊网络接口将多个网络接口绑定

到一个通道。根据选择的绑定模式 , 通道绑定使两个或更多个

网络接口作为一个网络接口 , 从而增加带宽和 / 提供冗余性

模式 0 ( 平衡轮循 ) - 轮循策略 , 所有接口都使用采用轮循

方式在所有 Slave 中传输封包 ; 任何 Slave 都可以接收

模式 1 ( 主动备份 ) - 容错。一次只能使用一个 Slave 接口

, 但是如果该接口出现故障 , 另一个 Slave 将 接替它

模式 3 ( 广播 ) - 容错。所有封包都通过所有 Slave 接口广

bond接口支持2块网卡

nm-connection-editor图形界面删除所有连接

3.配置网卡

[root@desktop Desktop]# ifcofig     ##查看网卡

3.

[root@desktop Desktop]# brctl addbr br0  ##添加br0网桥

[root@desktop Desktop]# ifconfig br0 172.25.12.10 netmask 255.255.255.0   ##配置ip和子网掩码

[root@desktop Desktop]# brctl addif br0 eth0                              ##添加网桥连接

图示:添加网桥

图示:添加成功

[root@desktop Desktop]# ifconfig br0 down      ##除去网桥

[root@desktop Desktop]# brctl delif br0 eth0   ##删除网桥连接

图示:除去删除网桥

[root@desktop Desktop]# systemctl start NetworkManager   开启NetworkManager

[root@desktop Desktop]# nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.12.10/24

图示:添加bond0

查看接口状态

[root@desktop Desktop]# nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0 

[root@desktop Desktop]# nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0 

图示:添加接口

测试:

[root@desktop Desktop]# ifconfig eth0 down

[root@desktop Desktop]# ifconfig eth0 up

[root@desktop Desktop]# ifconfig eth1 down

[root@desktop Desktop]# ifconfig eth1 up

图示:测试监控

4.删除

[root@desktop Desktop]# nmcli connection delete eth0  

[root@desktop Desktop]# nmcli connection delete bond0 

[root@desktop Desktop]# nmcli connection delete eth0

[root@desktop Desktop]# nmcli connection delete eth1

图示:删除结果

二、Team接口

1.team的简单介绍

team也是链路聚合的一种方式

最多支持8块网卡

支持模式

broadcast        广播容错

roundrobin       平衡轮叫

activebackup     主备

loadbalance      负载均衡

2.设置team

 nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.100/24

 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

图示:team0接口制作成功

[root@desktop Desktop]# nmcli connection add con-name eth0 ifname eth0 type team-slave master team0

[root@desktop Desktop]# nmcli connection add con-name eth1 ifname eth1 type team-slave master team0 

图示:添加

[root@desktop Desktop]# nmcli connection show    ##查看接口

图示:查看

[root@desktop Desktop]# nmcli connection delete team0

[root@desktop Desktop]# nmcli connection show

图示:删除

1.配置

vim /etc/sysconfig/network-scripts/ifcfg-enp1s0        ##此文件设备名每个主机不相同,针对各自主机进行修改

DEVICE=enp1s0                  ##设备名称

ONBOOT=yes                      ##开启服务设备自动激活

BOOTPROTO=none           ##网卡工作状态

BRIDGE=br0                        ##网卡开启的网桥接口

vim /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0

ONBOOT=yes

BOOTPROTO=none

IPADDR=172.25.254.98

NETMASK=255.255.255.0

TYPE=Bridge                     ##网络接口类型是桥接

systemctl stop NetworkManager.service

systemctl restart network

systemctl start NetworkManager.service

图示:更改配置

2.命令管理方式

#添加

systemctl stop NetworkManager

brctl show

brctl addbr br0

brctl addif br0 eth0

ifconfig eth0 up

ifconfig br0 172.25.254.x netmask 255.255.255.0

ping 172.25.254.250

#删除

ifconfig br0 down

brctl delif br0 eth0

brctl delbr br0

##end##

本文转自 無緣 51CTO博客,原文链接:http://blog.51cto.com/13352594/2045982

继续阅读