8.网络技术——VLAN(链路聚合)+路由器(静态路由)理论实践

本文介绍了交换机的链路类型,如接入链路和中继链路,并讲解了IEEE802.1q帧格式。重点探讨了三层交换机技术,包括VLAN间的通信和不同VLAN的互通。实验部分涉及二层和三层交换机的Eth-Trunk链路聚合配置,包括手工负载分担和LACP模式。通过配置静态路由,实现了全网设备的互通,确保了网络的稳定性和可靠性。
摘要由CSDN通过智能技术生成

目录

1.交换机的相关知识

交换机网络中的链路类型:接入链路、中继链路
在以太网上实现中继,有两种类型:ISL(Cisco私有标准)、IEEE 802.1q
IEEE 802.1q的帧格式:

2.三层交换机技术

三层交换机技术:
1)使用三层交换技术实现VLAN之间的通信
2)三层交换=二层交换+三层转发
三层交换机实现不同VLAN间互通
三层交换机多用于核心层:路由功能+高速转发

传统的MLS:
交换ASIC从3蹭引擎中获悉2蹭重写信息在硬件中创建一个MLS条目
负责重写和转发数据流中的后续数据包

基于CEF的MLS:
转发信息库(FIB)
邻接关系表

虚拟口概述:

interface vlan vlan-id //配置虚拟口

Eth-Trunk(链路聚合技术)
Eth-Trunk可以用于二层的链路聚合,也可以用于三层的链路聚合。缺省情况下,以太网接口工作在二层模式。如果需要配置二层Eth-Trunk接口,可以通过portswitch命令将该接口切换成二层接口;如果需要配置三层Eth-Trunk接口,可以通过undo portswitch命令将该接口切换成三层接口。

根据不同的链路聚合模式,Eth-Trunk接口可以实现增加带宽、负载分担等功能,帮助提高网络的可靠性

Eth-Trunk链路聚合模式分为:
手工负载分担模式
LACP模式

手工负载分担模式:是一种最基本的链路聚合方式,在该模式下,Eth-Trunk 接口的建立,成员接口的加入完全由手工来配置,没有链路聚合控制协议的参与。

静态LACP模式:利用LACP协议进行聚合参数协商、确定活动接口和非活动接口链路聚合方式。也称作N:M模式。

静态LACP模式和手工负载分担模式区分:静态LACP模式有备份链路,手工负载分担模式所有成员接口均处于转发状态,分担负载流量。

3.实验一

实验要求:全网互通

  1. 二层交换机之间做lacp链路聚合
  2. r1到r4有一条链路做浮动路由

拓补图:

PC1到PC7里面的IP地址,子网网关自己配好
交换机的配置,我这里是从LSW2开始配的
LSW2:

[sw2]vlan batch 10 20
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]p l a 
[sw2-Ethernet0/0/1]p d v 10
[sw2-Ethernet0/0/1]int e0/0/2
[sw2-Ethernet0/0/2]p l a 
[sw2-Ethernet0/0/2]p d v 20
[sw2-Ethernet0/0/2]int e0/0/3
[sw2-Ethernet0/0/3]p l t
[sw2-Ethernet0/0/3]p t a v a
[sw2-Ethernet0/0/3]q
[sw2]int Eth-tr	     //进入trunk 口配置
[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]p l t
[sw2-Eth-Trunk1]p t a v a
[sw2-Eth-Trunk1]trunkport e 0/0/4 to 0/0/6 
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2-Eth-Trunk1]mode manual load-balance  //设置模式
[sw2-Eth-Trunk1]dis this //查看一下 配置的命令

LSW3:

[sw3]vlan batch 30 40
[sw3]int e0/0/1
[sw3-Ethernet0/0/1]p l a 
[sw3-Ethernet0/0/1]p d v 30
[sw3-Ethernet0/0/1]int e0/0/2
[sw3-Ethernet0/0/2]p l a 
[sw3-Ethernet0/0/2]p d v 40
[sw3-Ethernet0/0/2]int e0/0/3
[sw3-Ethernet0/0/3]p l t
[sw3-Ethernet0/0/3]p t a v a
[sw3-Ethernet0/0/3]q
[sw3]int Eth-tr	
[sw3]int Eth-Trunk 1     // 拓补图上是两部分接口,以不同的标签备注
[sw3-Eth-Trunk1]p l t
[sw3-Eth-Trunk1]p t a v a
[sw3-Eth-Trunk1]trunkport e 0/0/4 to 0/0/6
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-Eth-Trunk1]mode manual load-balance 
[sw3-Eth-Trunk1]q
[sw3]int Eth-tr	
[sw3]int Eth-Trunk 2
[sw3-Eth-Trunk2]p l t 
[sw3-Eth-Trunk2]p t a v a
[sw3-Eth-Trunk2]tru	
[sw3-Eth-Trunk2]trunkport e 0/0/7 to 0/0/9
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw3-Eth-Trunk2]mode manual load-balance 
[sw3-Eth-Trunk2]dis this

同理如上

LSW4:

[sw4]vlan batch 50 60
[sw4]int e0/0/1
[sw4-Ethernet0/0/1]p l a 
[sw4-Ethernet0/0/1]p d v 50
[sw4-Ethernet0/0/1]int e0/0/2
[sw4-Ethernet0/0/2]p l a 
[sw4-Ethernet0/0/2]p d v 60
[sw4-Ethernet0/0/2]int e0/0/3
[sw4-Ethernet0/0/3]p l t
[sw4-Ethernet0/0/3]p t a v a
[sw4-Ethernet0/0/3]q
[sw4]int Eth-Trunk 2  // 需要跟前面配置的部分的trunk号相同
[sw4-Eth-Trunk2]p l t
[sw4-Eth-Trunk2]p t a v a
[sw4-Eth-Trunk2]trunkport e 0/0/4 to 0/0/6
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw4-Eth-Trunk2]mode manual load-balance 
[sw4-Eth-Trunk2]dis this

LSW1:

[sw1]vlan b 10 20 30 40 50 60 70
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]p l t
[sw1-GigabitEthernet0/0/1]p t a v a
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]p l t
[sw1-GigabitEthernet0/0/2]p t a v a
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]p l t
[sw1-GigabitEthernet0/0/3]p t a v a
[sw1-GigabitEthernet0/0/3]q
[sw1]int vlan 10  //进入虚拟的vlan 配置地址,这里的地址是以下pc机的各个网关
[sw1-Vlanif10]ip add 192.168.10.254 24
[sw1-Vlanif10]int vlan 20
[sw1-Vlanif20]ip add 192.168.20.254 24
[sw1-Vlanif20]int vlan 30
[sw1-Vlanif30]ip add 192.168.30.254 24
[sw1-Vlanif30]int vlan 40
[sw1-Vlanif40]ip add 192.168.40.254 24
[sw1-Vlanif40]int vlan 50
[sw1-Vlanif50]ip add 192.168.50.254 24
[sw1-Vlanif50]int vlan 60
[sw1-Vlanif60]ip add 192.168.60.254 24
[sw1-Vlanif60]q
[sw1]int g0/0/4   //因为之后的题目,所以这个口配置的接口模式是acess  这里配置一个虚拟的地址,用于静态路由的配置,后面会标注
[sw1-GigabitEthernet0/0/4]p l a
[sw1-GigabitEthernet0/0/]p d v 70
[sw1]int vlanif 70
[sw1-Vlanif70]ip add 10.0.0.1 24
[sw1-Vlanif70]dis this

这里可以看到目前是可以相互ping通的

这个PC1pingPC7的地址,里面经过路由,命令在下面会详细体现出来,接下来配置 静态路由的命令:


自己给每个接口之间设置网段 10.0.0.0 20.0.0.0 30.0.0.0 40.0.0.0 50.0.0.0 自己配置好两个端口的IP地址

因为sw1是一个三层交换机,具有路由器的功能,所以我在sw1里面配上静态路由,去往各个网段,都要在arp路由表里面可以体现出来,告诉它需要去的网段的 路径,下一跳地址

sw1的代码:

[sw1]ip route-s	
[sw1]ip route-static 20.0.0.0 24 10.0.0.2
[sw1]ip route-static 30.0.0.0 24 10.0.0.2
[sw1]ip route-static 40.0.0.0 24 10.0.0.2
[sw1]ip route-static 50.0.0.0 24 10.0.0.2
[sw1]ip route-static 192.168.70.0 24 10.0.0.2

AR1的代码:

[r1]
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 10.0.0.2 24
[r1-GigabitEthernet0/0/0]int g0/0/1
[r1-GigabitEthernet0/0/1]ip add 20.0.0.1 24
[r1-GigabitEthernet0/0/1]int g2/0/0
[r1-GigabitEthernet2/0/0]ip add 40.0.0.1 24
[r1-GigabitEthernet2/0/0]q    //以上是配置各个接口的地址
[r1]ip route-s	
[r1]ip route-static 192.168.10.0 24 10.0.0.1
[r1]ip route-static 192.168.20.0 24 10.0.0.1
[r1]ip route-static 192.168.30.0 24 10.0.0.1
[r1]ip route-static 192.168.40.0 24 10.0.0.1
[r1]ip route-static 192.168.50.0 24 10.0.0.1
[r1]ip route-static 192.168.60.0 24 10.0.0.1
[r1]ip route-static 192.168.70.0 24 20.0.0.2
[r1]ip route-static 192.168.70.0 24 40.0.0.2 preference 70  //浮动路由的优先级
[r1]ip route-static 30.0.0.0 24 20.0.0.2  //注意,这里也需要也需要配置一下静态路由,告诉它路径选择

AR2的代码:

The device is running!
<Huawei>sys
[Huawei]sysname r2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 20.0.0.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 30.0.0.1 24
[r2-GigabitEthernet0/0/1]
[r2]ip route-static 192.168.10.0 24 20.0.0.1
[r2]ip route-static 192.168.20.0 24 20.0.0.1
[r2]ip route-static 192.168.30.0 24 20.0.0.1
[r2]ip route-static 192.168.40.0 24 20.0.0.1
[r2]ip route-static 192.168.50.0 24 20.0.0.1
[r2]ip route-static 192.168.60.0 24 20.0.0.1
[r2]ip route-static 192.168.70.0 24 30.0.0.2
[r2]ip route-static 10.0.0.0 24 20.0.0.1    //路由与路由之间 也需要明确路径跟下一跳地址

AR3的代码:

The device is running!
[Huawei]sysname r3
[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 40.0.0.2 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 50.0.0.1 24
[r3]ip route-static 192.168.10.0 24 40.0.0.1
[r3]ip route-static 192.168.20.0 24 40.0.0.1
[r3]ip route-static 192.168.30.0 24 40.0.0.1
[r3]ip route-static 192.168.40.0 24 40.0.0.1
[r3]ip route-static 192.168.50.0 24 40.0.0.1
[r3]ip route-static 192.168.60.0 24 40.0.0.1
[r3]ip route-static 192.168.70.0 24 50.0.0.2

AR4的代码:

The device is running!
[r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 30.0.0.2 24
[r4-GigabitEthernet0/0/0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 192.168.70.254 24
[r4-GigabitEthernet0/0/1]int g2/0/0
[r4-GigabitEthernet2/0/0]ip add 50.0.0.2 24
[r4]ip route-static 192.168.10.0 24 30.0.0.1
[r4]ip route-static 192.168.20.0 24 30.0.0.1
[r4]ip route-static 192.168.30.0 24 30.0.0.1
[r4]ip route-static 192.168.40.0 24 30.0.0.1
[r4]ip route-static 192.168.50.0 24 30.0.0.1
[r4]ip route-static 192.168.60.0 24 30.0.0.1   //正常配置  静态路由
[r4]ip route-static 192.168.10.0 24 50.0.0.1 preference 70
[r4]ip route-static 192.168.20.0 24 50.0.0.1 preference 70
[r4]ip route-static 192.168.30.0 24 50.0.0.1 preference 70
[r4]ip route-static 192.168.40.0 24 50.0.0.1 preference 70
[r4]ip route-static 192.168.50.0 24 50.0.0.1 preference 70
[r4]ip route-static 192.168.60.0 24 50.0.0.1 preference 70   //配置浮动路由
[r4]ip route-static 20.0.0.0 24 30.0.0.1
[r4]ip route-static 10.0.0.0 24 30.0.0.1
[r4]ip route-static 40.0.0.0 24 50.0.0.1
[r4]ip route-static 10.0.0.0 24 50.0.0.1  //配置去往各个网段的静态路由,有来有回
[r4]

体现效果,pc1从192.168.10.0 网段 可以ping 通 pc7的 192.168.70.0 网段,途中经过了交换机跟路由器。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值