linux之网络桥接和链路聚合

本文详细介绍了Linux系统中的网络桥接和链路聚合技术。在网络桥接部分,阐述了如何配置真实网卡、桥接网卡,并展示了临时添加和删除br0接口的步骤。在链路聚合部分,讲解了bond和team两种链路聚合方式的设定与测试过程,以提升网络连接的稳定性和带宽。
一、网络桥接

桥接指的是在主机网卡上重新打开一个接口,分别连接主机和虚拟机,使虚拟机和真机处于同一个网段,降低网络延迟;

1、真实网卡配置:

在这里插入图片描述

2、桥接网卡配置:

在这里插入图片描述

3、临时添加br0接口:
brctl addbr br0			添加接口
ifconfig br0 ip			配置ip
brctl addif br0 eth0 	使br0连接到eth0

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4、删除临时设定:
ifconfig br0 down
brctl delbr br0

在这里插入图片描述

二、链路聚合
1、bond链路聚合
设定:
清理所有网卡
	nmcli connection delete
添加聚合链路接口:
	nmcli connection add con-name bond0 ifname bond0 type bond mode active-backup ip4 172.25.254.100/24
添加网卡到bond接口(主备模式)
	第一块网卡:nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
	第二块网卡:nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

测试
第一个窗口:
	watch -n 1 /proc/net/bonding/bond0
第二个窗口:
	ping 172.25.254.100
第三个窗口:
	ifconfig eth0 down

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、team链路聚合
1、设定
清理所有网卡
	nmcli connection delete
添加聚合链路接口:
	nmcli connection add con-name team0 type team ifname team0 config '{"runner":{"name":"$"}}' 172.25.254.100/24
	$--->the type of tead_mode
	man -k team		查看所有和team相关的文件
	man -5 tead.conf	
添加网卡到bond接口(主备模式)
	第一块网卡: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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2、测试
第一个窗口:
	watch -n 1 teamdctl team0 state
第二个窗口:
	ping 172.25.254.100
第三个窗口:
	ifconfig eth0 down

在这里插入图片描述在这里插入图片描述
在这里插入图片描述

Linux系统中,链路聚合(Link Aggregation,也称为LAG或Bonding)是一种技术,用于将两个或更多物理网卡连接组合成一个逻辑网络接口,提高网络带宽、可靠性容错能力。以下是实现Linux网卡链路聚合的一般步骤: 1. **启用内核支持**: - 确保你的内核已开启`bonding`模块,如果没有,可以编辑`/etc/modprobe.conf`,添加 `options bonding mode=0`,然后运行`modprobe bonding`。 2. **配置loif(Loopback Interface)**: 创建一个名为`bond0`的接口,通常作为桥接设备,用于承载聚合后的流量。在`/etc/network/interfaces`或`/etc/sysconfig/network-scripts`文件中,增加类似下面的内容: ```bash auto bond0 iface bond0 inet manual bond_mode active-backup bond_device eth0 eth1 ``` 或者选择其他模式,如`mode=balance-rr`(轮询)、`mode=802.3ad`(LACP)等。 3. **设置网卡**: - 配置每个物理网卡(eth0 eth1),使其成为`bond0`的一部分,例如: ``` echo "bond0" >> /sys/class/net/eth0/bonding/slaves echo "bond0" >> /sys/class/net/eth1/bonding/slaves ``` 4. **激活并启动接口**: - 使用`ip addr add`命令为`bond0`分配IP地址其他网络配置,然后启用启动它: ``` ip link set bond0 up ifup bond0 ``` 5. **验证检查状态**: 可以使用`ethtool`命令查看每个网卡的状态以及聚合的详细信息: ``` ethtool bond0 ``` 6. **防火墙规则调整**(如果需要): 需要确保防火墙允许聚合端口间的通信。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值