linux下的网络接口和网络桥接

1.bond网络接口的介绍

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

工作模式
roundrobin平衡轮询模式:两块网卡轮流接收数据包。由于两块网卡都正常工作,它能提供两倍的带宽,在这种情况下出现一块网卡失效,仅仅会是服务器出口带宽下降,也不会影响网络使用。

activebackup主动备份模式:只有主网卡 eth0 工作,eth1 作为备份网卡是不工作的,只有当一个网络接口失效时 ( 例如主交换机掉电等 ),为了不会出现网络中断,系统会按照配置指定的网卡顺序启动工作,保证机器仍能对外服务,起到了失效保护的功能。
bond网络接口只支持两块网卡绑定。

2.bond网络接口的建立

先建立bond网络接口,并添加IP地址:
nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.134/24
在这里插入图片描述
将网卡eth0添加到bond接口中:
nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
在这里插入图片描述
将网卡eth1添加到bond接口中:
nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
在这里插入图片描述
查看工作状态:
在这里插入图片描述
模拟网卡eth0出故障时,网络不会断掉,会由eth1接替eth0工作:
ifconfig eth0 down #模拟网卡eth0不工作
在这里插入图片描述
就算网卡eth0恢复正常,bond依然由eth1工作:
在这里插入图片描述
在这里插入图片描述

3.team网络接口的介绍

网卡绑定bond可以提高网络的冗余,保证网络可靠性,提高网络速度。为了提高网络容错或吞吐量,一般服务器都会采取多网卡绑定的策略,在RHEL5/RHEL6中使用的是Bond。而RHEL7提供了一项新的实现技术Team,用来实现链路聚合的功能,但是在RHEL7中,不会使用team替换bond,它们是并存的,我们可以选择Team,也可以选择Bond。
该接口与bond接口功能类似,但该接口可以支持八块网卡,不需要手动加载相应内核模块该接口比bond接口多一个模式。

4.team网络接口的搭建

先建立team网络接口,并添加IP地址:
nmcli connection add con-name team0 ifname team0 type team config ‘{“runner”:{“activebackup”}}’ ip4 172.25.254.134/24
在这里插入图片描述
将网卡eth0添加到team接口中:
nmcli connection add con-name eth0 ifname eth0 type team-slave master team0
在这里插入图片描述
将网卡eth1添加到team接口中:
nmcli connection add con-name eth1 ifname eth1 type team-slave master team0
在这里插入图片描述
systemctl restart network
nmcli connection show
在这里插入图片描述
teamdctl team0 stat
在这里插入图片描述

5.网络桥接

网络桥接是用来连接不同的网段,使虚拟机的网卡直接连接到真机的真实网卡,使上网速度更快。
1.用命令临时添加网桥:
brctl show #查看主机原有的网桥
brctl addbr br0 #添加新的网桥
brctl show #查看是否添加成功
在这里插入图片描述
ifconfig br0 172.25.254.134/24 #给br0添加IP
ifconfig #查看是否添加成功
在这里插入图片描述
在这里插入图片描述
brctl show #查看网桥状态,没有真实的物理设备与网桥对应
brctl addif br0 eth0 #使网卡eth0与网桥br0对应
brctl show #查看是否对应成功
ping 172.25.254.34 #查看网桥是否建立成功
在这里插入图片描述
2.删除网桥:
brctl delif br0 eth0 #解除对应关系
brctl show
ifconfig br0 down #关闭网桥
brctl show
在这里插入图片描述
brctl delbr br0 #删除网桥
systemctl restart network #重启网络
brctl show #查看是否成功删除
在这里插入图片描述
3.用文件永久添加网桥:
vim /etc/sysconfig/network-scripts/ifcfg-br0 #建立网桥
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.134
PREFIX=24
TYPE=Bridge
在这里插入图片描述
vim /etc/sysconfig/network-scripts/ifcfg-eth0 #使网卡eth0与网桥对应
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
BRIDGE=br0
在这里插入图片描述
systemctl restart network
brctl show
ping 172.25.254.34
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值