2024年8月29日 08:54:50
This commit is contained in:
parent
123b02ca8a
commit
db8e5d5016
@ -261,4 +261,149 @@
|
||||
查看S2的instance 2 g0/0/5 g0/0/6都是指定接口
|
||||
```
|
||||
|
||||
|
||||
3. 实验MSTP负载均衡
|
||||
|
||||
![image-20240828193446020](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828193446020.png)
|
||||
|
||||
- 需求
|
||||
|
||||
- PC1属于 vlan 10 ,IP地址为 192.168.10.1/24,网关为 192.168.10.254
|
||||
- PC2属于 vlan 20 ,IP地址为 192.168.20.1/24,网关为 192.168.20.254
|
||||
- 确保PC1与PC2互通
|
||||
- 配置 MSTP ,SW1为 vlan10的主根、vlan20的次根,SW2为vlan10的主根、vlan10的次根
|
||||
|
||||
- 配置步骤
|
||||
|
||||
1. 配置PC的IP地址
|
||||
2. 在所有的交换机中都创建vlan10和vlan20
|
||||
3. 交换机连接PC的接口设置为access模式,并加入指定的vlan
|
||||
4. 交换机和交换机互联的接口设置trunk模式,并允许vlan10和vlan20 通过
|
||||
5. 在所有的交换机中配置MSTP,所有交换机中的MSTP配置都要完全相同
|
||||
6. 指定SW1为vlan10的主根, vlan20的备根
|
||||
7. 指定SW2为vlan20的主根, vlan10的备根
|
||||
8. 配置路由器接口的IP地址
|
||||
|
||||
- 配置命令
|
||||
|
||||
- S1、S2、S3创建vlan并配置连接交换机的端口为trunk
|
||||
|
||||
```
|
||||
[S1]VLAN batch 10 20
|
||||
[S1]port-group 1
|
||||
[S1-port-group-1]group-member G0/0/5 G0/0/6
|
||||
[S1-port-group-1]port link-type trunk
|
||||
[S1-GigabitEthernet0/0/5]port trunk allow-pass vlan ALL
|
||||
```
|
||||
|
||||
```
|
||||
[S2]VLAN batch 10 20
|
||||
[S2]port-group 1
|
||||
[S2-port-group-1]group-member G0/0/5 G0/0/6
|
||||
[S2-port-group-1]port link-type trunk
|
||||
[S2-GigabitEthernet0/0/5]port trunk allow-pass vlan ALL
|
||||
```
|
||||
|
||||
```
|
||||
[S3]VLAN batch 10 20
|
||||
[S3]port-group 1
|
||||
[S3-port-group-1]group-member G0/0/5 G0/0/6
|
||||
[S3-port-group-1]port link-type trunk
|
||||
[S3-GigabitEthernet0/0/5]port trunk allow-pass vlan ALL
|
||||
```
|
||||
|
||||
- S1、S2、S3配置MSTP区域并激活
|
||||
|
||||
```
|
||||
[S1]stp mode mstp 启用MSTP协议
|
||||
[S1]stp region-configuration 创建区域
|
||||
[S1-mst-region]region-name ntd 定义区域名为ntd
|
||||
[S1-mst-region]instance 1 vlan 10 指定vlan与实例的对应关系
|
||||
[S1-mst-region]instance 2 vlan 20
|
||||
[S1-mst-region]active region-configuration 激活区域配置
|
||||
```
|
||||
|
||||
```
|
||||
[S2]stp mode mstp 启用MSTP协议
|
||||
[S2]stp region-configuration 创建区域
|
||||
[S2-mst-region]region-name ntd 定义区域名为ntd
|
||||
[S2-mst-region]instance 1 vlan 10 指定vlan与实例的对应关系
|
||||
[S2-mst-region]instance 2 vlan 20
|
||||
[S2-mst-region]active region-configuration 激活区域配置
|
||||
```
|
||||
|
||||
```
|
||||
[S3]stp mode mstp 启用MSTP协议
|
||||
[S3]stp region-configuration 创建区域
|
||||
[S3-mst-region]region-name ntd 定义区域名为ntd
|
||||
[S3-mst-region]instance 1 vlan 10 指定vlan与实例的对应关系
|
||||
[S3-mst-region]instance 2 vlan 20
|
||||
[S3-mst-region]active region-configuration 激活区域配置
|
||||
```
|
||||
|
||||
- 配置S1为vlan10的主根、vlan20的次根网桥并查看配置
|
||||
|
||||
```
|
||||
[S1]stp instance 1 priority 0
|
||||
[S1]stp instance 2 priority 4096
|
||||
```
|
||||
|
||||
- 配置S2为vlan20的主根、vlan10的次根根网桥并查看配置
|
||||
|
||||
```
|
||||
[S2]stp instance 2 priority 0
|
||||
[S2]stp instance 1 priority 4096
|
||||
```
|
||||
|
||||
- 配置PC1加入vlan10、PC2加入vlan20
|
||||
|
||||
```
|
||||
[S3]interface GigabitEthernet 0/0/1
|
||||
[S3-GigabitEthernet0/0/1]port link-type access
|
||||
[S3-GigabitEthernet0/0/1]port default vlan 10
|
||||
[S3]interface GigabitEthernet 0/0/2
|
||||
[S3-GigabitEthernet0/0/2]port link-type access
|
||||
[S3-GigabitEthernet0/0/2]port default vlan 20
|
||||
```
|
||||
|
||||
- 配置S1与路由相连的接口加入vlan10
|
||||
|
||||
```
|
||||
[S1]interface GigabitEthernet 0/0/1
|
||||
[S1-GigabitEthernet0/0/1]port link-type access
|
||||
[S1-GigabitEthernet0/0/1]port default vlan 10
|
||||
```
|
||||
|
||||
- 配置S2与路由相连的接口加入 vlan20
|
||||
|
||||
```
|
||||
[S2]interface GigabitEthernet 0/0/2
|
||||
[S2-GigabitEthernet0/0/2]port link-type access
|
||||
[S2-GigabitEthernet0/0/2]port default vlan 20
|
||||
```
|
||||
|
||||
- 配置路由器接口IP
|
||||
|
||||
```
|
||||
[R1]interface GigabitEthernet 0/0/1
|
||||
[R1-GigabitEthernet0/0/1]ip address 192.168.10.254 24
|
||||
[R1]interface GigabitEthernet 0/0/2
|
||||
[R1-GigabitEthernet0/0/2]ip address 192.168.20.254 24
|
||||
```
|
||||
|
||||
- 测试与验证
|
||||
|
||||
```
|
||||
pc1 ping pc2 通
|
||||
```
|
||||
|
||||
- 查看验证
|
||||
|
||||
```
|
||||
<S1>display stp instance 1 brief
|
||||
查看S1的instance 1 g0/0/5 g0/0/6都是指定接口
|
||||
```
|
||||
|
||||
```
|
||||
<S2>display stp instance 2 brief
|
||||
查看S2的instance 2 g0/0/5 g0/0/6都是指定接口
|
||||
```
|
120
A. 第一阶段/14_VLAN间通信.md
Normal file
120
A. 第一阶段/14_VLAN间通信.md
Normal file
@ -0,0 +1,120 @@
|
||||
# VLAN间通信
|
||||
|
||||
### 一、VLANIF虚接口
|
||||
|
||||
1. 三层交换机是具有网络层路由功能的交换机
|
||||
2. VLANIF接口是一种三层虚拟接口,可以实现VLAN间的三层互通
|
||||
3. VLANIF配置接口IP地址,作为VLAN内主机的网关
|
||||
|
||||
### 二、VLANIF虚接口实验
|
||||
|
||||
![image-20240828194442794](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828194442794.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
> 让所有vlan内的所有pc主机都可以互通
|
||||
|
||||
- **配置步骤**
|
||||
|
||||
- 配置PC的IP地址和掩码、网关
|
||||
- 交换机SW2/SW3 上创建VLAN,配置接口接口加入VLAN
|
||||
- 在SW1上创建VLAN,并且给VLANIF 虚拟接口配置IP地址
|
||||
|
||||
- **配置命令**
|
||||
|
||||
- SW1配置
|
||||
|
||||
```
|
||||
[SW1]vlan batch 10 20 30 40
|
||||
[SW1]port-group group-member g0/0/1 g0/0/2
|
||||
[SW1-port-group]port link-type trunk
|
||||
[SW1-port-group]port trunk allow-pass vlan all
|
||||
[SW1-port-group]quit
|
||||
[SW1]interface vlanif 10
|
||||
[SW1-vlanif10] ip address 192.168.10.254 24
|
||||
[SW1-vlanif10]interface vlanif 20
|
||||
[SW1-vlanif20]ip address 192.168.20.254 24
|
||||
[SW1-vlanif20]interface vlanif 30
|
||||
[SW1-vlanif30]ip address 192.168.30.254 24
|
||||
[SW1-vlanif30]interface vlanif 40
|
||||
[SW1-vlanif40]ip address 192.168.40.254 24
|
||||
```
|
||||
|
||||
- SW2配置
|
||||
|
||||
```
|
||||
[SW2]vlan batch 10 20 30 40
|
||||
[SW2]interface g0/0/1
|
||||
[SW2-g0/0/1]port link-type trunk
|
||||
[SW2-g0/0/1]port trunk allow-pass vlan all
|
||||
[SW2-g0/0/1]interface g0/0/2
|
||||
[SW2-g0/0/2]port link-type access
|
||||
[SW2-g0/0/2]port default vlan 10
|
||||
[SW2-g0/0/2]interface g0/0/3
|
||||
[SW2-g0/0/3]port link-type access
|
||||
[SW2-g0/0/3]port default vlan 20
|
||||
```
|
||||
|
||||
- SW3配置
|
||||
|
||||
```
|
||||
[SW3]vlan batch 10 20 30 40
|
||||
[SW3]interface g0/0/1
|
||||
[SW3-g0/0/1]port link-type trunk
|
||||
[SW3-g0/0/1]port trunk allow-pass vlan all
|
||||
[SW3-g0/0/1]interface g0/0/2
|
||||
[SW3-g0/0/2]port link-type access
|
||||
[SW3-g0/0/2]port default vlan 30
|
||||
[SW3-g0/0/2]interface g0/0/3
|
||||
[SW3-g0/0/3]port link-type access
|
||||
[SW3-g0/0/3]port default vlan 40
|
||||
```
|
||||
|
||||
- 测试与验证
|
||||
|
||||
```
|
||||
Vlan10主机192.168.10.1 ping 192.168.20.1
|
||||
192.168.30.1
|
||||
192.168.40.1
|
||||
```
|
||||
|
||||
### 三、三层交换连接路由实现全网互通
|
||||
|
||||
![image-20240828194823206](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828194823206.png)
|
||||
|
||||
- 配置步骤1:通过三层交换实现vlan10,vlan20,vlan30,vlan40之间的通信(具体命令参考1前一个实验)
|
||||
|
||||
- 配置步骤2:配置三层交换连接路由器并实现全网互通用
|
||||
|
||||
- 三层交换机配置
|
||||
|
||||
```
|
||||
[S3]vlan 50
|
||||
[S3]interfaceVlanif 50
|
||||
[S3-Vlanif50]IPaddress 192.168.50.1 24
|
||||
[S3]interfaceGigabitEthernet 0/0/1
|
||||
[S3-GigabitEthernet0/0/1]portlink-type access
|
||||
[S3-GigabitEthernet0/0/1]portdefault vlan 50
|
||||
[S3]IP route-static 192.168.60.0 24 192.168.50.2
|
||||
```
|
||||
|
||||
路由配置
|
||||
|
||||
```
|
||||
[R1]interfaceGigabitEthernet 0/0/0
|
||||
[R1-GigabitEthernet0/0/0]IPaddress 192.168.60.254 24
|
||||
[R1]interfaceGigabitEthernet 0/0/1
|
||||
[R1-GigabitEthernet0/0/1]IPaddress 192.168.50.2 24
|
||||
[R1]ip route-static 0.0.0.0 0 192.168.50.1
|
||||
```
|
||||
|
||||
- 验证
|
||||
|
||||
```
|
||||
192.168.60.1的主机 ping 192.168.10.1
|
||||
192.168.20.1
|
||||
192.168.30.1
|
||||
192.168.40.1
|
||||
```
|
||||
|
||||
|
127
A. 第一阶段/15_VLAN聚合.md
Normal file
127
A. 第一阶段/15_VLAN聚合.md
Normal file
@ -0,0 +1,127 @@
|
||||
# VLAN聚合
|
||||
|
||||
### 一、什么是VLAN聚合
|
||||
|
||||
- **VLAN聚合:也称Super VLAN(超级VLAN)**
|
||||
|
||||
- 指在一个物理网络内,将多个VLAN(称为Sub-VLAN:子VLAN),聚合成一个逻辑的VLAN(称为Super-VLAN:超级VLAN)
|
||||
|
||||
- 这些Sub-VLAN使用同一个IP子网和网关,从而达到节约IP地址的目的
|
||||
|
||||
### 二、VLAN聚合的作用
|
||||
|
||||
- 节约了子网网络号、子网广播地址、子网网关地址
|
||||
- 节约空闲的IP地址,防止IP地址浪费
|
||||
- 提高IP地址编制的灵活性
|
||||
|
||||
#### 三、VLAN聚合实验
|
||||
|
||||
![image-20240828195237124](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828195237124.png)
|
||||
|
||||
- 需求
|
||||
|
||||
> 公司vlan2/vlan3/vlan4都使用超级vlan10的IP子网网段 -公司内部不同vlan内的主机可以互通(vlan间通信)
|
||||
>
|
||||
> 每个vlan内的主机都可以和R1互通
|
||||
|
||||
- 配置步骤
|
||||
|
||||
- 第一步:配置PC的IP地址,掩码,网关
|
||||
- 第二步:创建子VLAN 1)在sw2/sw3/sw4上创建vlan 2 3 4 2)交换机连接PC的接口设置为access模式,并将接口加入指定的vlan 3)交换机互联接口设置为trunk模式,允许vlan 2 3 4 通过
|
||||
- 第三步:创建超级VLAN,并开启代理ARP,实现vlan间通信
|
||||
1. 在sw1上创建vlan 2 3 4 10
|
||||
2. sw1与sw2/sw3/sw4互联接口设置为trunk模式,允许vlan 2 3 4 通过
|
||||
3. 在sw1 上配置超级vlan ,并配置vlanif10 虚接口地址
|
||||
4. 在sw1 上启用super-vlan 的proxy ARP功能
|
||||
- 第四步:配置路由,实现VLAN内的主机与R1通信
|
||||
1. sw1与R1互联的接口设置为access模式,加入vlan20 ,并配置vlanif20 虚接口IP地址
|
||||
2. 在R1中配置去往192.168.10.0/24的静态路由,下一跳指向192.168.20.10
|
||||
- 第五步:测试与验证
|
||||
|
||||
- 配置命令
|
||||
|
||||
- 第一步:配置PC的IP地址,掩码,网关
|
||||
|
||||
- 第二步:创建子VLAN
|
||||
|
||||
- SW2配置
|
||||
|
||||
```
|
||||
[SW2]vlan batch 2 3 4
|
||||
[SW2]port-group group-member g0/0/2 g0/0/3
|
||||
[SW2-port-group]port link-type access
|
||||
[SW2-port-group]port default vlan 2
|
||||
[SW2-port-group]quit
|
||||
[SW2]int g0/0/1
|
||||
[SW2-GigabitEthernet0/0/1]port link-type trunk
|
||||
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- SW3配置
|
||||
|
||||
```
|
||||
[SW3]vlan batch 2 3 4
|
||||
[SW3]port-group group-member g0/0/2 g0/0/3
|
||||
[SW3-port-group]port link-type access
|
||||
[SW3-port-group]port default vlan 3
|
||||
[SW3-port-group]quit
|
||||
[SW3]int g0/0/1
|
||||
[SW3-GigabitEthernet0/0/1]port link-type trunk
|
||||
[SW3-GigabitEthernet0/0/1]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- SW4配置
|
||||
|
||||
```
|
||||
[SW4]vlan batch 2 3 4
|
||||
[SW4]port-group group-member g0/0/2 g0/0/3
|
||||
[SW4-port-group]port link-type access
|
||||
[SW4-port-group]port default vlan 4
|
||||
[SW4-port-group]quit
|
||||
[SW4]int g0/0/1
|
||||
[SW4-GigabitEthernet0/0/1]port link-type trunk
|
||||
[SW4-GigabitEthernet0/0/1]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- 第三步:创建超级VLAN,并开启代理ARP,实现vlan间通信(实现PC之间互通)
|
||||
|
||||
- SW1配置
|
||||
|
||||
```
|
||||
[SW1]vlan batch 2 3 4 10
|
||||
[SW1]vlan 10 //进入vlan10
|
||||
[SW1-vlan10]aggregate-vlan //配置vlan10为聚合vlan(超级vlan)
|
||||
[SW1-vlan10]access-vlan 2 to 4 //在聚合vlan10中添加子vlan2/3/4
|
||||
[SW1-vlan10]quit
|
||||
[SW1]interface vlanif 10 //进入vlanif 10
|
||||
[SW1-Vlanif10]ip address 192.168.10.254 24 //配置vlanif10虚接口的IP地址
|
||||
[SW1-Vlanif10]arp-proxy inter-sub-vlan-proxy enable //在vlanif10下开启vlan间-arp代理
|
||||
[SW1-Vlanif10]quit
|
||||
[SW1]port-group group-member g0/0/2 to g0/0/4
|
||||
[SW1-port-group]port link-type trunk
|
||||
[SW1-port-group]port trunk allow-pass vlan 2 3 4
|
||||
```
|
||||
|
||||
- 第四步:配置路由,实现VLAN内的主机与R1互通
|
||||
|
||||
- SW1配置
|
||||
|
||||
```
|
||||
[SW1]vlan batch 20 //创建vlan20
|
||||
[SW1]int g0/0/1
|
||||
[SW1-GigabitEthernet0/0/1]port link-type access
|
||||
[SW1-GigabitEthernet0/0/1]port default vlan 20
|
||||
[SW1-GigabitEthernet0/0/1]quit
|
||||
[SW1]int vlanif 20
|
||||
[SW1-Vlanif20]ip address 192.168.20.10 24
|
||||
```
|
||||
|
||||
- R1路由器配置
|
||||
|
||||
```
|
||||
[R1]int g0/0/0
|
||||
[R1-GigabitEthernet0/0/0]ip address 192.168.20.20 24
|
||||
[R1]ip route-static 192.168.10.0 24 192.168.20.10 //配置静态路由
|
||||
```
|
||||
|
||||
|
81
A. 第一阶段/16_端口隔离.md
Normal file
81
A. 第一阶段/16_端口隔离.md
Normal file
@ -0,0 +1,81 @@
|
||||
# 端口隔离
|
||||
|
||||
### 一、端口隔离概述
|
||||
|
||||
1. 端口隔离的作用:采用端口隔离功能,可以实现同一VLAN内端口之间的隔离。
|
||||
2. 如何实现端口隔离功能:只需要将端口加入到隔离组中,就可以实现隔离组内端口之间二层数据的隔离。
|
||||
3. 端口隔离的优势:节约了VLAN,提供了更安全、更灵活的组网方案
|
||||
|
||||
### 二、端口隔离的特点
|
||||
|
||||
- 隔离组的接口和其他接口之间不隔离
|
||||
- 不同端口隔离组的接口之间不隔离
|
||||
- 端口隔离只是针对同一设备上的端口隔离组成员,对于不同设备上的接口而言,无法实现该功能
|
||||
|
||||
> 同一设备同一隔离组内的主机之间互相隔离
|
||||
|
||||
### 三、端口隔离实验
|
||||
|
||||
![image-20240828195947885](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828195947885.png)
|
||||
|
||||
- 需求
|
||||
|
||||
- PC1/2/3/4都属于同一个 VLAN 100 -IP地址所在网段为 192.168.100.0/24,网关地址为 192.168.100.254
|
||||
- PC1和PC2不能通信,但是都可以访问 PC3和PC4 -所有的PC都可以访问 Server1
|
||||
|
||||
- 配置步骤
|
||||
|
||||
- 第一步:配置PC的IP地址,掩码,网关
|
||||
- 第二步:创建vlan,接口加入vlan -在交换机中创建vlan100 -交换机所有的接口都设置为access 模式,并加入vlan100
|
||||
- 第三步:配置端口隔离 -在交换机g0/0/1 和g0/0/2 接口下开启端口隔离功能,将2个接口加入端口隔离组1
|
||||
- 第四步:配置R1路由器的接口IP地址3
|
||||
- 第五步:验证与测试
|
||||
|
||||
- 配置命令
|
||||
|
||||
- 第一步:配置PC的IP地址、掩码、网关
|
||||
|
||||
- 第二步:创建vlan,接口加入vlan
|
||||
|
||||
- SW1配置
|
||||
|
||||
```
|
||||
[SW1]vlan 100
|
||||
[SW1-vlan100]quit
|
||||
[SW1]port-group group-member g0/0/1 to g0/0/5
|
||||
[SW1-port-group]port link-type access
|
||||
[SW1-port-group]port default vlan 100
|
||||
```
|
||||
|
||||
- 第三步:配置端口隔离
|
||||
|
||||
- SW1配置
|
||||
|
||||
```
|
||||
[SW1]port-group group-member g0/0/1 g0/0/2
|
||||
[SW1-port-group]port-isolate enable group 1
|
||||
```
|
||||
|
||||
- 第四步:配置R1路由器的接口IP地址
|
||||
|
||||
- R1配置
|
||||
|
||||
```
|
||||
[R1]int g0/0/1
|
||||
[R1-GigabitEthernet0/0/1]ip add 192.168.88.254 24
|
||||
[R1-GigabitEthernet0/0/1]int g0/0/0
|
||||
[R1-GigabitEthernet0/0/0]ip add 192.168.100.254 24
|
||||
```
|
||||
|
||||
- 第五步:验证与测试
|
||||
|
||||
```
|
||||
PC1 ping PC2 不通
|
||||
PC1 ping PC3/4 都通
|
||||
PC2 ping PC3/4 都通
|
||||
所有的PC ping server1 都通
|
||||
|
||||
[SW1]display port-isolate group all //查看端口隔离配置
|
||||
```
|
||||
|
||||
|
409
A. 第一阶段/17_DHCP.md
Normal file
409
A. 第一阶段/17_DHCP.md
Normal file
@ -0,0 +1,409 @@
|
||||
# DHCP
|
||||
|
||||
### 一、DHCP概述
|
||||
|
||||
1. **DHCP是什么**
|
||||
|
||||
- DHCP:Dynamic Host Configuration Protocol :动态主机配置协议
|
||||
- DHCP是一种集中对用户IP地址进行动态管理和配置的技术
|
||||
|
||||
2. **DHCP的作用**
|
||||
|
||||
- 作用:实现IP地址的动态分配和集中管理
|
||||
- 优势:避免手工配置IP地址,提高工作效率,避免出错,且能快速适应网络的变化
|
||||
|
||||
3. **DHCP角色**
|
||||
|
||||
- DHCP客户端:需要获取IP地址的设备,如:计算机、服务器、手机、IP电话等
|
||||
|
||||
- DHCP服务器:负责为DHCP客户端分配IP地址等网络参数的设备
|
||||
|
||||
- DHCP 中继(中转站-可选):负责DHCP服务器和DHCP客户端之间的DHCP报文(房地产中介公司)
|
||||
|
||||
> 企业网络中一般不需要部署DHCP中继
|
||||
|
||||
### 二、DHCP服务器给首次接入网络的客户端分配网络参数的工作原理
|
||||
|
||||
1. **发现阶段**:客户端广播发送DHCP Discover报文(DHCP发现报文,客户端找DHCP服务器,请求IP地址)
|
||||
2. **提供阶段**:服务器收到客户端发的报文后,会单播回复DHCP Offer报文(DHCP回应报文,服务器给客户端发IP地址、网关、DNS等)
|
||||
3. **选择阶段**:客户端收到Offer报文后,会再次广播发送DHCP Request报文(DHCP请求报文,客户端广播告知所有的服务器,选择了某某IP地址)
|
||||
4. **确认阶段**:服务器收到客户端发报文后,会单播回复DHCP ACK报文(DHCP确认报文,确认分配结果,只有发了ACK报文,客户端才可以使用IP)
|
||||
|
||||
### 三、基于全局的DHCP实验
|
||||
|
||||
![image-20240828200710881](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828200710881.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
> PC1/PC2能够自动获取IP地址、网关、DNS
|
||||
|
||||
- **配置步骤**
|
||||
|
||||
- 第一步:在系统视图下开启DHCP功能
|
||||
- 第二步:配置IP地址池
|
||||
- 创建IP地址池
|
||||
- 配置可分配的IP地址段
|
||||
- 配置网关地址
|
||||
- 配置DNS地址
|
||||
- 配置租期
|
||||
- 第三步:配置R1路由器接口的IP地址
|
||||
- 这个接口接收客户端发的报文,这个接口的IP地址,即客户端的网关地址
|
||||
- 在这个接口下开启基于全局的DHCP功能
|
||||
- 第四步:验证结果
|
||||
|
||||
- **配置命令**
|
||||
|
||||
- R1的配置
|
||||
|
||||
```
|
||||
[R1]dhcp enable //开启DHCP功能
|
||||
[R1]ip pool tedu //创建IP地址池
|
||||
[R1-ip-pool-tedu]network 192.168.1.0 mask 24 //配置可分配的地址段
|
||||
[R1-ip-pool-tedu]gateway-list 192.168.1.254 //配置网关地址
|
||||
[R1-ip-pool-tedu]dns-list 8.8.8.8 //配置DNS地址
|
||||
[R1-ip-pool-tedu]lease day 1 //配置租期
|
||||
[R1-ip-pool-tedu]quit
|
||||
[R1]int g0/0/0
|
||||
[R1-G0/0/0]ip address 192.168.1.254 24 //此接口IP地址和网关地址一致
|
||||
[R1-G0/0/0]dhcp select global //在接口下开启基于全局的DHCP
|
||||
```
|
||||
|
||||
- 验证与测试
|
||||
|
||||
> PC1和PC2选择获取地址的方式为DHCP
|
||||
> 然后PC1和PC2在命令行中,使用ipconfig 命令查看IP地址
|
||||
|
||||
- 数据抓包
|
||||
|
||||
![image-20240828201014044](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828201014044.png)
|
||||
|
||||
- 配置地址排除
|
||||
|
||||
```
|
||||
[R1]ip pool tedu
|
||||
[R1-ip-pool-tedu]excluded-ip-address 192.168.1.250 192.168.1.253 //在基于全局的IP地址池中做地址排除,排除的IP地址不做dhcp分发
|
||||
```
|
||||
|
||||
- 查看IP地址池
|
||||
|
||||
```
|
||||
<R1>display ip pool name tedu all //查看全局IP地址池中全部地址信息
|
||||
<R1>display ip pool name tedu used //查看全局IP地址池中已分发的IP地址
|
||||
```
|
||||
|
||||
### 四、基于接口的DHCP实验
|
||||
|
||||
![image-20240828201131434](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828201131434.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
> PC1/PC2能够自动获取IP地址、网关、DNS
|
||||
|
||||
- **配置步骤**
|
||||
|
||||
- 第一步:在系统视图下开启DHCP功能
|
||||
- 第二步:配置基于接口的DHCP
|
||||
- 配置接口的IP地址和掩码
|
||||
- 在接口下开启基于接口的DHCP功能
|
||||
- 在接口下配置DNS地址
|
||||
- 在接口下配置租期
|
||||
|
||||
- **配置命令**
|
||||
|
||||
- R1配置
|
||||
|
||||
```
|
||||
[R1]dhcp enable //开启dhcp功能
|
||||
[R1]int g0/0/0
|
||||
[R1-G0/0/0]ip address 192.168.1.254 24
|
||||
[R1-G0/0/0]dhcp select interface //开启基于接口的dhcp 功能
|
||||
[R1-G0/0/0]dhcp server dns-list 8.8.8.8
|
||||
[R1-G0/0/0]dhcp server lease day 1
|
||||
```
|
||||
|
||||
- **验证与测试**
|
||||
|
||||
> PC1和PC2选择获取地址的方式为DHCP
|
||||
> 然后PC1和PC2在命令行中,使用ipconfig 命令查看IP地址
|
||||
|
||||
### 五、DHCP中继代理原理
|
||||
|
||||
- **问题**
|
||||
|
||||
> 当客户机和DHCP服务器不在一个广播域时,DHCP服务器无法接收到客户机的DHCP discover广播数据包,客户机就无法获得IP地
|
||||
|
||||
- **解决**
|
||||
|
||||
> 在客户机所在的广播域中,寻找一台路由器,这台路由器一个端口在客户机所在的广播域,另外一个端口在DHCP服务器所在的广播域,让这台路由器主动接收客户机的DHCP discover数据包,然后由这台路由器代替客户机向DHCP服务器申请IP地址,得到地址后,再把这个地址交给客户机,这台服务器称之为DHCP中继代理服务器
|
||||
|
||||
- **DHCP中继实验**
|
||||
|
||||
![image-20240828201521120](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240828201521120.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
- 希望PC1/PC2自动获取到IP地址,网关、DNS等网络参数
|
||||
- Server1 服务器手工配置一个静态IP地址,192.168.10.253,这个地址是专门给服务器使用的,所以这个地址不能通过DHCP分发,避免IP地址冲突
|
||||
|
||||
- **配置步骤**
|
||||
|
||||
- 第一步:配置R2-DHCP服务器
|
||||
1. 在系统视图下开启DHCP功能
|
||||
2. 在R2-DHCP服务器中配置基于全局的DHCP
|
||||
- 创建IP地址池:ntd
|
||||
- 定义网段:192.168.10.0/24
|
||||
- 定义网关:192.168.10.254
|
||||
- 定于DNS:8.8.8.8
|
||||
- 定义排除地址:192.168.10.253 这个IP地址不做DHCP分发
|
||||
3. 在接口上配置IP地址,开启基于全局的dhcp
|
||||
- 第二步:配置DHCP中继
|
||||
1. R1中继设备开启DHCP功能
|
||||
2. 配置R1中继设备的接口IP地址
|
||||
3. 在R1设备连接客户端的接口上开启DHCP中继,指向DHCP服务器:192.168.20.20
|
||||
- 第三步:配置静态路由
|
||||
- 在R2配置去往192.168.10.0网段的路由,下一跳为192.168.20.10
|
||||
- 第四步:验证与测试
|
||||
|
||||
- **配置命令**
|
||||
|
||||
- 第一步:配置DHCP服务器
|
||||
|
||||
- DHCP服务器配置
|
||||
|
||||
```
|
||||
[R2-DHCP]dhcp enable //开启dhcp 功能
|
||||
[R2-DHCP]ip pool ntd //创建IP地址池
|
||||
[R2-DHCP-ip-pool-ntd]network 192.168.10.0 mask 24
|
||||
[R2-DHCP-ip-pool-ntd]gateway-list 192.168.10.254
|
||||
[R2-DHCP-ip-pool-ntd]dns-list 8.8.8.8
|
||||
[R2-DHCP-ip-pool-ntd]excluded-ip-address 192.168.10.253
|
||||
[R2-DHCP-ip-pool-ntd]quit
|
||||
[R2-DHCP]int g0/0/0
|
||||
[R2-DHCP-GigabitEthernet0/0/0]ip add 192.168.20.20 24
|
||||
[R2-DHCP-GigabitEthernet0/0/0]dhcp select global
|
||||
```
|
||||
|
||||
- 第二步:配置DHCP中继
|
||||
|
||||
```
|
||||
[R1-zj]dhcp enable
|
||||
[R1-zj]int g0/0/0
|
||||
[R1-zj-G0/0/0]ip add 192.168.20.10 24
|
||||
|
||||
[R1-zj-G0/0/0]int g0/0/1
|
||||
[R1-zj-G0/0/1]ip add 192.168.10.254 24
|
||||
[R1-zj-G0/0/1]dhcp select relay //在接口上开启dhcp中继功能
|
||||
[R1-zj-G0/0/1]dhcp relay server-ip 192.168.20.2 //指定dhcp服务器的IP地址
|
||||
```
|
||||
|
||||
- 第三步:在DHCP服务器上配置去往中继设备的回程路由
|
||||
|
||||
```
|
||||
[R2-DHCP]ip route-static 192.168.10.0 24 192.168.20.10
|
||||
```
|
||||
|
||||
- 第四步:验证与测试
|
||||
|
||||
```
|
||||
在PC1和PC2中设置IP地址的获取方式为DHCP
|
||||
在PC1和PC2中命令行中输入命令
|
||||
```
|
||||
|
||||
- **经验证发现**
|
||||
|
||||
```
|
||||
PC1的IP地址是192.168.10.252
|
||||
PC2的IP地址是192.168.10.251
|
||||
192.168.10.253这个地址,已经被排除,没有被DHCP分发
|
||||
```
|
||||
|
||||
### 六、三层交换机部署DHCP
|
||||
|
||||
![image-20240829083619899](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240829083619899.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
> vlan10和vlan20的pc自动获取IP地址
|
||||
|
||||
- **配置步骤**
|
||||
|
||||
- 第一步:在sw1部署dhcp
|
||||
1. 创建vlan
|
||||
2. 配置trunk链路-交换机互联接口做trunk
|
||||
3. 配置vlanif 虚接口地址--每个vlan的网关地址
|
||||
4. 开启dhcp 功能
|
||||
5. 创建IP地址池
|
||||
- 定义网段
|
||||
- 定义网关
|
||||
- 定义dns
|
||||
6. 在vlanif 虚接口下,开启dhcp select global
|
||||
- 第二步:配置sw2和sw3接入层交换机
|
||||
1. 创建vlan
|
||||
2. 接口加入vlan,交换机和pc互联的接口做access
|
||||
3. 交换机和交换机互联的接口做trunk
|
||||
- 第三步:验证与测试
|
||||
|
||||
- **配置命令**
|
||||
|
||||
- 第一步:在sw1部署dhcp
|
||||
|
||||
- DHCP服务器配置
|
||||
|
||||
```
|
||||
[SW1-DHCP]vlan batch 10 20
|
||||
[SW1-DHCP]port-group group-member g0/0/1 g0/0/2
|
||||
[SW1-DHCP-port-group]port link-type trunk
|
||||
[SW1-DHCP-port-group]port trunk allow-pass vlan all
|
||||
[SW1-DHCP-port-group]quit
|
||||
[SW1-DHCP]ip pool vlan10
|
||||
[SW1-DHCP-ip-pool-vlan10]network 192.168.10.0 mask 24
|
||||
[SW1-DHCP-ip-pool-vlan10]gateway-list 192.168.10.254
|
||||
[SW1-DHCP-ip-pool-vlan10]dns-list 8.8.8.8
|
||||
[SW1-DHCP-ip-pool-vlan10]quit
|
||||
[SW1-DHCP]ip pool vlan20
|
||||
[SW1-DHCP-ip-pool-vlan20]network 192.168.20.0 mask 24
|
||||
[SW1-DHCP-ip-pool-vlan20]gateway-list 192.168.20.254
|
||||
[SW1-DHCP-ip-pool-vlan20]dns-list 8.8.8.8
|
||||
[SW1-DHCP-ip-pool-vlan20]quit
|
||||
[SW1-DHCP]dhcp enable
|
||||
[SW1-DHCP]int vlanif 10
|
||||
[SW1-DHCP-Vlanif10]ip address 192.168.10.254 24
|
||||
[SW1-DHCP-Vlanif10]dhcp select global
|
||||
[SW1-DHCP-Vlanif10]int vlanif 20
|
||||
[SW1-DHCP-Vlanif20]ip address 192.168.20.254 24
|
||||
[SW1-DHCP-Vlanif20]dhcp select global
|
||||
```
|
||||
|
||||
- 第二步:配置sw2和sw3接入层交换机
|
||||
|
||||
- SW2配置
|
||||
|
||||
```
|
||||
[SW2]vlan batch 10 20
|
||||
[SW2]port-group group-member g0/0/2 g0/0/3
|
||||
[SW2-port-group]port link-type access
|
||||
[SW2-port-group]port default vlan 10
|
||||
[SW2-port-group]quit
|
||||
[SW2]int g0/0/1
|
||||
[SW2-G0/0/1]port link-type trunk
|
||||
[SW2-G0/0/1]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- SW3配置
|
||||
|
||||
```
|
||||
[SW3]vlan batch 10 20
|
||||
[SW3]port-group group-member g0/0/2 g0/0/3
|
||||
[SW3-port-group]port link-type access
|
||||
[SW3-port-group]port default vlan 20
|
||||
[SW3-port-group]quit
|
||||
[SW3]int g0/0/1
|
||||
[SW3-G0/0/1]port link-type trunk
|
||||
[SW3-G0/0/1]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- 第三步:验证与测试
|
||||
|
||||
- 在PC1和PC2中设置IP地址的获取方式为DHCP
|
||||
|
||||
- 在PC1和PC2中命令行中输入命令
|
||||
|
||||
```
|
||||
ipconfig /release //释放当前IP地址
|
||||
ipconfig /renew //更新IP地址(获取IP地址)
|
||||
```
|
||||
|
||||
```
|
||||
<SW1-DHCP>display ip pool name vlan10 all //查看地址池中全部IP信息
|
||||
<SW1-DHCP>display ip pool name vlan10 used //查看地址中已使用的IP地址
|
||||
<SW1-DHCP>display ip pool name vlan20 all //查看地址池中全部IP信息
|
||||
<SW1-DHCP>display ip pool name vlan20 used //查看地址中已使用的IP地址
|
||||
```
|
||||
|
||||
```
|
||||
<S3>reset ip pool name vlan10 192.168.10.253回收已分配的IP地址
|
||||
<S3>reset ip pool name vlan10 all
|
||||
```
|
||||
|
||||
### 七、租期
|
||||
|
||||
> 1)租期T1:
|
||||
> 当IP地址的租用时间到达50%时,客户机会以单播方式向服务器发送Request 请求报文,请求更新IP地址租期。
|
||||
> DHCP 服务器如果回复DHCP ACK确认报文给客户机,代表租期更新成功,从0开始
|
||||
|
||||
> 2)租期T2
|
||||
> 如果DHCP服务器一直没有回应,那么在IP地址的租用时间到达87.5%时,客户机会以广播方式向服务器发送Request 请求报文,请求更新IP地址租期
|
||||
> DHCP服务器如果回复DHCP ACK 确认报文给客户机,代表租期更新成功,从0开始
|
||||
|
||||
1. **access接口恢复默认配置(缺省配置)**
|
||||
|
||||
```
|
||||
[SW1]vlan batch 10 20
|
||||
[SW1]interface g0/0/1
|
||||
[SW1-GigabitEthernet0/0/1]port link-type access
|
||||
[SW1-GigabitEthernet0/0/1]port default vlan 10
|
||||
[SW1-GigabitEthernet0/0/1]port link-type trunk //将接口模式修改为trunk(失败)
|
||||
Error: Please renew the default configurations. :错误:请更新默认配置
|
||||
```
|
||||
|
||||
- 如何解决:如何恢复接口上VLAN的缺省配置
|
||||
|
||||
- 第一种方法
|
||||
|
||||
```
|
||||
[SW1-GigabitEthernet0/0/1]port default vlan 1 //接口pvid恢复为vlan1
|
||||
[SW1-GigabitEthernet0/0/1]port link-type trunk //将接口模式修改为trunk(成功)
|
||||
```
|
||||
|
||||
- 第二种方法
|
||||
|
||||
```
|
||||
[SW1-GigabitEthernet0/0/1]undo port default vlan //恢复接口上VLAN的缺省配置
|
||||
[SW1-GigabitEthernet0/0/1]port link-type trunk //将接口模式修改为trunk(成功)
|
||||
```
|
||||
|
||||
2. **trunk接口恢复默认配置(缺省配置)**
|
||||
|
||||
```
|
||||
[SW1]vlan batch 10 20
|
||||
[SW1]interface g0/0/1
|
||||
[SW1-G0/0/1]port link-type trunk
|
||||
[SW1-G0/0/1]port trunk allow-pass vlan 10 20
|
||||
[SW1-G0/0/1]port link-type access //将接口模式修改为access(失败)
|
||||
Error: Please renew the default configurations. :错误:请更新默认配置
|
||||
```
|
||||
|
||||
- 如何解决:如何恢复接口上VLAN的缺省配置
|
||||
|
||||
```
|
||||
[SW1-G0/0/1]undo port trunk allow-pass vlan 10 20 //恢复默认
|
||||
[SW1-G0/0/1]port link-type access //将接口模式修改为access(成功)
|
||||
```
|
||||
|
||||
- 备注:
|
||||
|
||||
```
|
||||
[SW1-G0/0/1]undo port trunk allow-pass vlan all //删除所有vlan
|
||||
[SW1-G0/0/1]port link-type access //无法修改报错
|
||||
Error: Please renew the default configurations.
|
||||
```
|
||||
|
||||
- 如何解决:恢复默认配置: undo port trunk allow-pass vlan all 的时候把所有vlan 都干掉了
|
||||
所以我们要恢复vlan1
|
||||
|
||||
- 第一种方法
|
||||
|
||||
```
|
||||
[SW1-G0/0/1]undo port trunk allow-pass vlan 2 to 4094 //只删除2 to 4094 不删除vlan1
|
||||
[SW1-G0/0/1]port link-type access //修改成功
|
||||
```
|
||||
|
||||
- 第二种方法
|
||||
|
||||
```
|
||||
[SW1-G0/0/1]undo port trunk allow-pass vlan all //删除所有vlan
|
||||
[SW1-G0/0/1]port trunk allow-pass vlan 1 //补上vlan1,恢复默认
|
||||
[SW1-G0/0/1]port link-type access //修改成功
|
||||
```
|
||||
|
||||
|
@ -1,90 +0,0 @@
|
||||
# VRRP
|
||||
|
||||
![image-20240827112252447](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240827112252447.png)
|
||||
|
||||
### 一、配PC的IP、子网掩码、网关
|
||||
|
||||
### 二、配路由交换机接口的IP、VLAN、VRRP
|
||||
|
||||
- **SW1**
|
||||
|
||||
```
|
||||
<Huawei>u t m
|
||||
<Huawei>sys
|
||||
[Huawei]sys SW1
|
||||
[SW1]vlan 10
|
||||
[SW1-vlan10]quit
|
||||
[SW1]port-group group-member g0/0/1 to g0/0/4
|
||||
[SW1-port-group]port link-type access
|
||||
[SW1-port-group]port default vlan 10
|
||||
[SW1-port-group]return
|
||||
<SW1>save
|
||||
```
|
||||
|
||||
- **AR1**
|
||||
|
||||
```
|
||||
<Huawei>u t m
|
||||
<Huawei>sys
|
||||
[Huawei]sys AR1
|
||||
[AR1]int g0/0/0
|
||||
[AR1-GigabitEthernet0/0/0]ip a 192.168.1.251 24
|
||||
[AR1-GigabitEthernet0/0/0]int g0/0/1
|
||||
[AR1-GigabitEthernet0/0/1]ip a 192.168.13.1 24
|
||||
[AR1-GigabitEthernet0/0/1]quit
|
||||
[AR1]int g0/0/0
|
||||
[AR1-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254
|
||||
[AR1-GigabitEthernet0/0/0]vrrp vrid 1 priority 130
|
||||
[AR1-GigabitEthernet0/0/0]quit
|
||||
[AR1]ip route-static 192.168.2.0 24 192.168.13.3
|
||||
[AR1]quit
|
||||
<AR1>save
|
||||
```
|
||||
|
||||
- **AR2**
|
||||
|
||||
```
|
||||
<Huawei>u t m
|
||||
<Huawei>sys
|
||||
[Huawei]sys AR2
|
||||
[AR2]int g0/0/0
|
||||
[AR2-GigabitEthernet0/0/0]ip a 192.168.1.252 24
|
||||
[AR2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.1.254
|
||||
[AR2-GigabitEthernet0/0/0]int g0/0/1
|
||||
[AR2-GigabitEthernet0/0/1]ip a 192.168.23.1 24
|
||||
[AR2-GigabitEthernet0/0/1]quit
|
||||
[AR2]ip route-static 192.168.2.0 24 192.168.23.3
|
||||
[AR2]quit
|
||||
<AR2>save
|
||||
```
|
||||
|
||||
- **AR3**
|
||||
|
||||
```
|
||||
<Huawei>u t m
|
||||
<Huawei>sys
|
||||
[Huawei]sys AR3
|
||||
[AR3]int g 0/0/0
|
||||
[AR3-GigabitEthernet0/0/0]ip a 192.168.13.3 24
|
||||
[AR3-GigabitEthernet0/0/0]int g0/0/1
|
||||
[AR3-GigabitEthernet0/0/1]ip a 192.168.23.3 24
|
||||
[AR3-GigabitEthernet0/0/1]int g0/0/2
|
||||
[AR3-GigabitEthernet0/0/2]ip a 192.168.2.254 24
|
||||
[AR3-GigabitEthernet0/0/2]quit
|
||||
[AR3]ip route-static 192.168.1.0 24 192.168.23.1 preference 70
|
||||
[AR3]quit
|
||||
<AR3>save
|
||||
```
|
||||
|
||||
### 三、拓展:上行接口监控(上行链路跟踪)
|
||||
|
||||
- **AR1**
|
||||
|
||||
```
|
||||
[R1]int g0/0/0
|
||||
[AR1-GigabitEthernet0/0/0]vrrp vrid 10 track int g0/0/1 reduced 50
|
||||
```
|
||||
|
||||
> 配置 VRRP 跟踪功能,监视接口 g0/0/1 的状态。如果该接口故障,VRRP 的优先级将减少 50
|
||||
|
||||
![批注 2024-08-27 113731](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/%E6%89%B9%E6%B3%A8%202024-08-27%20113731.png)
|
@ -1,301 +0,0 @@
|
||||
# 多VLAN环境下的VRRP负载分担
|
||||
|
||||
![image-20240827161558989](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240827161558989.png)
|
||||
|
||||
- **需求**
|
||||
|
||||
- SW1
|
||||
|
||||
```
|
||||
备份组10:
|
||||
SW1-master设备
|
||||
作用:转发VLAN10用户上网数据
|
||||
优先级:130
|
||||
|
||||
备份组20:
|
||||
SW1-backup设备
|
||||
作用:监控备份组20的master设备
|
||||
优先级:默认100
|
||||
```
|
||||
|
||||
- SW2
|
||||
|
||||
```
|
||||
备份组10:
|
||||
SW2-backup设备
|
||||
作用:监控备份组10的master设备
|
||||
优先级:默认100
|
||||
|
||||
备份组20:
|
||||
SW2-master设备
|
||||
作用:转发VLAN20用户上网数据
|
||||
优先级:130
|
||||
```
|
||||
|
||||
### 一、配置PC、服务器、路由的IP、子网掩码、网关
|
||||
|
||||
- **AR1**
|
||||
|
||||
```
|
||||
[AR1]int g0/0/0
|
||||
[AR1-GigabitEthernet0/0/0]ip add 192.168.13.3 24
|
||||
[AR1-GigabitEthernet0/0/0]int g0/0/1
|
||||
[AR1-GigabitEthernet0/0/1]ip add 192.168.23.3 24
|
||||
[AR1-GigabitEthernet0/0/1]int g0/0/2
|
||||
[AR1-GigabitEthernet0/0/2]ip add 192.168.2.254 24
|
||||
```
|
||||
|
||||
### 二、配置交换机VLAN
|
||||
|
||||
- **SW3**
|
||||
|
||||
```
|
||||
[SW3]vlan batch 10 20
|
||||
[SW3]int g0/0/1
|
||||
[SW3-GigabitEthernet0/0/1]port link-type access
|
||||
[SW3-GigabitEthernet0/0/1]port default vlan 10
|
||||
[SW3-GigabitEthernet0/0/1]int g0/0/2
|
||||
[SW3-GigabitEthernet0/0/2]port link-type access
|
||||
[SW3-GigabitEthernet0/0/2]port default vlan 20
|
||||
[SW3-GigabitEthernet0/0/2]quit
|
||||
[SW3]port-group group-member g0/0/3 g0/0/4
|
||||
[SW3-port-group]port link-type trunk
|
||||
[SW3-port-group]port trunk allow-pass vlan all
|
||||
```
|
||||
|
||||
- **SW1**
|
||||
|
||||
```
|
||||
[SW1]vlan 13
|
||||
[SW1-vlan13]quit
|
||||
[SW1-GigabitEthernet0/0/2]port link-type trunk
|
||||
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
|
||||
[SW1-GigabitEthernet0/0/2]int g0/0/1
|
||||
[SW1-GigabitEthernet0/0/1]port link-type access
|
||||
[SW1-GigabitEthernet0/0/1]port default vlan 13
|
||||
[SW1-GigabitEthernet0/0/1]quit
|
||||
[SW1]int vlan 13
|
||||
[SW1-Vlanif13]ip add 192.168.13.1 24
|
||||
```
|
||||
|
||||
- **SW2**
|
||||
|
||||
```
|
||||
[SW2]vlan 23
|
||||
[SW2-vlan23]quit
|
||||
[SW2]int g0/0/2
|
||||
[SW2-GigabitEthernet0/0/2]port link-type trunk
|
||||
[SW2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
|
||||
[SW2-GigabitEthernet0/0/2]int g0/0/1
|
||||
[SW2-GigabitEthernet0/0/1]port link-type access
|
||||
[SW2-GigabitEthernet0/0/1]port default vlan 23
|
||||
[SW2-GigabitEthernet0/0/1]quit
|
||||
[SW2]int vlan 23
|
||||
[SW2-Vlanif13]ip add 192.168.23.1 24
|
||||
```
|
||||
|
||||
### 三、配置VRRP
|
||||
|
||||
- **SW1**
|
||||
|
||||
```
|
||||
[SW1]vlan batch 10 20
|
||||
[SW1]int vlan 10
|
||||
[SW1-Vlanif10]ip add 192.168.10.251 24
|
||||
[SW1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||
[SW1-Vlanif10]vrrp vrid 10 priority 130
|
||||
[SW1-Vlanif10]vrrp vrid 10 track int g0/0/1 reduced 50
|
||||
[SW1-Vlanif10]int vlan 20
|
||||
[SW1-Vlanif20]ip add 192.168.20.251 24
|
||||
[SW1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
|
||||
```
|
||||
|
||||
- *注解*
|
||||
1. `[SW1]int vlan 10`:进入交换机 SW1 的配置模式,并创建或进入 VLAN 10 的接口配置。
|
||||
2. `[SW1-Vlanif10]ip add 192.168.10.251 24`:为 VLAN 10 的虚拟接口配置 IP 地址 192.168.10.251,子网掩码为 24 位。
|
||||
3. `[SW1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254`:在 VLAN 10 上配置 VRRP,设置虚拟路由器 ID 为 10,并指定虚拟 IP 地址为 192.168.10.254。
|
||||
4. `[SW1-Vlanif10]vrrp vrid 10 priority 130`:设置 VRRP 虚拟路由器 10 的优先级为 130。
|
||||
5. `[SW1-Vlanif10]vrrp vrid 10 track int g0/0/1 reduced 50`:配置 VRRP 跟踪功能,监视接口 g0/0/1 的状态。如果该接口故障,VRRP 的优先级将减少 50。
|
||||
6. `[SW1]int vlan 20`:创建或进入 VLAN 20 的接口配置。
|
||||
7. `[SW1-Vlanif20]ip add 192.168.20.251 24`:为 VLAN 20 的虚拟接口配置 IP 地址 192.168.20.251,子网掩码为 24 位。
|
||||
8. `[SW1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254`:在 VLAN 20 上配置 VRRP,设置虚拟路由器 ID 为 20,并指定虚拟 IP 地址为 192.168.20.254。
|
||||
|
||||
- **SW2**
|
||||
|
||||
```
|
||||
[SW2]vlan batch 10 20
|
||||
[SW2]int vlan 10
|
||||
[SW2-Vlanif10]ip add 192.168.10.252 24
|
||||
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||
[SW2-Vlanif10]int vlan 20
|
||||
[SW2-Vlanif20]ip add 192.168.20.252 24
|
||||
[SW2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
|
||||
[SW2-Vlanif20]vrrp vrid 20 priority 130
|
||||
[SW2-Vlanif20]vrrp vrid 20 track int g0/0/1 reduced 50
|
||||
```
|
||||
|
||||
- *注解*
|
||||
1. `[SW2]int vlan 10`:进入交换机 SW2 的配置模式,并创建或进入 VLAN 10 的接口配置。
|
||||
2. `[SW2-Vlanif10]ip add 192.168.10.252 24`:为 VLAN 10 的虚拟接口配置 IP 地址 192.168.10.252,子网掩码为 24 位。
|
||||
3. `[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254`:在 VLAN 10 上配置 VRRP,设置虚拟路由器 ID 为 10,并指定虚拟 IP 地址为 192.168.10.254(与 SW1 上的配置相同)。
|
||||
4. `[SW2]int vlan 20`:创建或进入 VLAN 20 的接口配置。
|
||||
5. `[SW2-Vlanif20]ip add 192.168.20.252 24`:为 VLAN 20 的虚拟接口配置 IP 地址 192.168.20.252,子网掩码为 24 位。
|
||||
6. `[SW2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254`:在 VLAN 20 上配置 VRRP,设置虚拟路由器 ID 为 20,并指定虚拟 IP 地址为 192.168.20.254(与 SW1 上的配置相同)。
|
||||
7. `[SW2-Vlanif20]vrrp vrid 20 priority 130`:设置 VRRP 虚拟路由器 20 的优先级为 130。
|
||||
8. `[SW2-Vlanif20]vrrp vrid 20 track int g0/0/1 reduced 50`:配置 VRRP 跟踪功能,监视接口 g0/0/1 的状态。如果该接口故障,VRRP 的优先级将减少 50。
|
||||
|
||||
- **总结**
|
||||
|
||||
- VLAN 10 和 VLAN 20 都在两台交换机上配置了 VRRP,虚拟 IP 地址分别为 192.168.10.254 和 192.168.20.254。
|
||||
- 在 VLAN 10 上,SW1 的优先级高于 SW2,因此 SW1 将成为主网关。
|
||||
- 在 VLAN 20 上,SW2 的优先级被设置为 130,高于 SW1 的默认优先级(通常为 100),因此 SW2 将成为主网关。
|
||||
- 如果 g0/0/1 接口故障,那么拥有该接口的交换机的 VRRP 优先级将降低,可能导致主备角色切换。
|
||||
|
||||
### 四、静态路由
|
||||
|
||||
- **SW1**
|
||||
|
||||
```
|
||||
[SW1]ip route-static 192.168.2.0 24 192.168.13.3
|
||||
```
|
||||
|
||||
- **SW2**
|
||||
|
||||
```
|
||||
[SW2]ip route-static 192.168.2.0 24 192.168.23.3
|
||||
```
|
||||
|
||||
- **AR1**
|
||||
|
||||
```
|
||||
[AR1]ip route-static 192.168.10.0 24 192.168.13.1
|
||||
[AR1]ip route-static 192.168.10.0 24 192.168.23.1 preference 100
|
||||
[AR1]ip route-static 192.168.20.0 24 192.168.13.1 preference 100
|
||||
[AR1]ip route-static 192.168.20.0 24 192.168.23.1
|
||||
```
|
||||
|
||||
### 五、连通性测试
|
||||
|
||||
- **PC1**
|
||||
|
||||
- PING 服务器
|
||||
|
||||
```
|
||||
PC1>ping 192.168.2.1
|
||||
|
||||
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
|
||||
From 192.168.2.1: bytes=32 seq=1 ttl=253 time=47 ms
|
||||
From 192.168.2.1: bytes=32 seq=2 ttl=253 time=47 ms
|
||||
From 192.168.2.1: bytes=32 seq=3 ttl=253 time=63 ms
|
||||
From 192.168.2.1: bytes=32 seq=4 ttl=253 time=62 ms
|
||||
From 192.168.2.1: bytes=32 seq=5 ttl=253 time=47 ms
|
||||
|
||||
--- 192.168.2.1 ping statistics ---
|
||||
5 packet(s) transmitted
|
||||
5 packet(s) received
|
||||
0.00% packet loss
|
||||
round-trip min/avg/max = 47/53/63 ms
|
||||
```
|
||||
|
||||
- Tracert 服务器
|
||||
|
||||
```
|
||||
PC1>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.10.251 16 ms 46 ms 47 ms
|
||||
2 192.168.13.3 63 ms 62 ms 78 ms
|
||||
3 192.168.2.1 63 ms 62 ms 63 ms
|
||||
```
|
||||
|
||||
- **PC2**
|
||||
|
||||
- PING 服务器
|
||||
|
||||
```
|
||||
PC2>ping 192.168.2.1
|
||||
|
||||
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
|
||||
From 192.168.2.1: bytes=32 seq=1 ttl=253 time=62 ms
|
||||
From 192.168.2.1: bytes=32 seq=2 ttl=253 time=63 ms
|
||||
From 192.168.2.1: bytes=32 seq=3 ttl=253 time=78 ms
|
||||
From 192.168.2.1: bytes=32 seq=4 ttl=253 time=78 ms
|
||||
From 192.168.2.1: bytes=32 seq=5 ttl=253 time=47 ms
|
||||
|
||||
--- 192.168.2.1 ping statistics ---
|
||||
5 packet(s) transmitted
|
||||
5 packet(s) received
|
||||
0.00% packet loss
|
||||
round-trip min/avg/max = 47/65/78 ms
|
||||
```
|
||||
|
||||
- Tracert 服务器
|
||||
|
||||
```
|
||||
PC2>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.20.252 31 ms 47 ms 31 ms
|
||||
2 192.168.23.3 62 ms 79 ms 62 ms
|
||||
3 192.168.2.1 63 ms 62 ms 63 ms
|
||||
```
|
||||
|
||||
### 六、功能性测试
|
||||
|
||||
- **左侧上行线断连**
|
||||
|
||||
![image-20240827200957958](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240827200957958.png)
|
||||
|
||||
- PC1 Tracert 服务器
|
||||
|
||||
```
|
||||
PC1>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.10.252 47 ms 47 ms 47 ms
|
||||
2 192.168.23.3 78 ms 62 ms 63 ms
|
||||
3 192.168.2.1 78 ms 62 ms 63 ms
|
||||
```
|
||||
|
||||
- PC2 Tracert 服务器
|
||||
|
||||
```
|
||||
PC2>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.20.252 62 ms 47 ms 47 ms
|
||||
2 192.168.23.3 62 ms 63 ms 62 ms
|
||||
3 192.168.2.1 78 ms 63 ms 62 ms
|
||||
```
|
||||
|
||||
- **右侧上行线断连**
|
||||
|
||||
![image-20240827201250325](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240827201250325.png)
|
||||
|
||||
- PC1 Tracert 服务器
|
||||
|
||||
```
|
||||
PC1>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.10.251 78 ms 31 ms 47 ms
|
||||
2 192.168.13.3 109 ms 78 ms 63 ms
|
||||
3 192.168.2.1 62 ms 63 ms 62 ms
|
||||
```
|
||||
|
||||
- PC2 Tracert 服务器
|
||||
|
||||
```
|
||||
PC2>tracert 192.168.2.1
|
||||
|
||||
traceroute to 192.168.2.1, 8 hops max
|
||||
(ICMP), press Ctrl+C to stop
|
||||
1 192.168.20.251 93 ms 32 ms 46 ms
|
||||
2 192.168.13.3 63 ms 62 ms 79 ms
|
||||
3 192.168.2.1 62 ms 94 ms 62 ms
|
||||
```
|
Loading…
Reference in New Issue
Block a user