2024年8月31日 11:59:13
This commit is contained in:
parent
bb07c2f5bf
commit
d1d9576526
@ -444,7 +444,464 @@
|
|||||||
3 192.168.2.1 47 ms 47 ms 31 ms
|
3 192.168.2.1 47 ms 47 ms 31 ms
|
||||||
```
|
```
|
||||||
|
|
||||||
### 七、知识总结
|
### 七、在交换机中部署VRRP
|
||||||
|
|
||||||
|
1. VRRP负载分担 - 多VLAN环境
|
||||||
|
|
||||||
|
![image-20240831101221398](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831101221398.png)
|
||||||
|
|
||||||
|
- **需求**
|
||||||
|
|
||||||
|
1. PC1属于vlan10 ,PC2属于vlan20
|
||||||
|
2. vlan10的主网关是SW1,备份网关是SW2,vlan10的数据流量默认由SW1转发
|
||||||
|
3. vlan20的主网关是SW2,备份网关是SW1,vlan20的数据流量默认由SW2转发
|
||||||
|
|
||||||
|
- **配置步骤**
|
||||||
|
|
||||||
|
- 第一步:配置PC和server的IP地址,掩码,网关
|
||||||
|
|
||||||
|
- 第二步:在sw10交换机
|
||||||
|
|
||||||
|
1. 创建vlan 10/20
|
||||||
|
2. 与PC互联的接口,配置access模式,并加入指定的vlan
|
||||||
|
3. 与交换机互联的接口配置trunk模式
|
||||||
|
|
||||||
|
- 第三步:SW1和SW2配置VRRP负载均衡
|
||||||
|
|
||||||
|
1. SW1交换机配置
|
||||||
|
|
||||||
|
- 在SW1中创建vlan 10/20/13
|
||||||
|
- 配置vlanif10的IP:192.168.10.251/24
|
||||||
|
- 配置vlanif20的IP:192.168.20.251/24
|
||||||
|
- 配置vlanif13的IP:192.168.13.1/24
|
||||||
|
- SW1和R3互联的接口g0/0/1加入vlan13
|
||||||
|
- SW1和SW10互联的接口配置为trunk
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
- 在SW1交换机的vlanif10虚接口下,配置VRRP
|
||||||
|
- 在vlanif10虚接口下创建备份组10的,并配置虚拟IP:192.168.10.254
|
||||||
|
- 配置备份组10的优先级为130
|
||||||
|
- 让SW1成为备份组10的Master-->让SW1成为vlan10的主网关
|
||||||
|
- 在备份组10中配置上行接口跟踪,当上行接口down的时候,优先级减去50
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
- 在SW1交换机的vlanif20虚接口下,配置VRRP
|
||||||
|
- 在vlanif20虚接口下创建备份组20的,并配置虚拟IP:192.168.20.254
|
||||||
|
- 让SW1成为备份组20的Backup-->SW1是vlan20的备份网关
|
||||||
|
|
||||||
|
2. SW2交换机配置
|
||||||
|
|
||||||
|
- 在SW2中创建vlan 10/20/23
|
||||||
|
- 配置vlanif10的IP:192.168.10.252/24
|
||||||
|
- 配置vlanif20的IP:192.168.20.252/24
|
||||||
|
- 配置vlanif23的IP:192.168.23.1/24
|
||||||
|
- SW2和R3互联的接口g0/0/1加入vlan23
|
||||||
|
- SW2和SW10互联的接口配置为trunk
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
- 在SW2交换机的vlanif10虚接口下,配置VRRP
|
||||||
|
- 在vlanif10虚接口下创建备份组10的,并配置虚拟IP:192.168.10.254
|
||||||
|
- 让SW2成为备份组10的Backup--SW2是vlan10的备份网关
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
- 在SW2交换机的vlanif20虚接口下,配置VRRP
|
||||||
|
- 在vlanif20虚接口下创建备份组20的,并配置虚拟IP:192.168.20.254
|
||||||
|
- 配置备份组20的优先级为130
|
||||||
|
- 让SW2成为备份组20的Master-->让SW2成为vlan20的主网关
|
||||||
|
- 在备份组20中配置上行接口跟踪,当上行接口down的时候,优先级减去50
|
||||||
|
|
||||||
|
- 第四步:SW1/SW2/R3配置静态路由
|
||||||
|
|
||||||
|
1. 配置R3的接口IP地址
|
||||||
|
2. R3配置去往192.168.10/24 网段的路由,下一跳为SW1
|
||||||
|
3. R3配置去往192.168.10/24 网段的路由,下一跳为SW2
|
||||||
|
4. R3配置去往192.168.20/24 网段的路由,下一跳为SW1
|
||||||
|
5. R3配置去往192.168.20/24 网段的路由,下一跳为SW2
|
||||||
|
6. SW1/SW2 配置去往192.168.2.0/24网段的路由,下一跳为R3的接口IP地址
|
||||||
|
|
||||||
|
- 第五步:验证VRRP
|
||||||
|
|
||||||
|
- PC1 ping server1 验证vlan10的数据依靠SW1转发
|
||||||
|
- PC2 ping server1 验证vlan20的数据依靠SW2转发
|
||||||
|
|
||||||
|
- **配置命令**
|
||||||
|
|
||||||
|
- 第一步:配置PC和server的IP地址,掩码,网关
|
||||||
|
|
||||||
|
- 第二步:在sw10交换机
|
||||||
|
|
||||||
|
- SW10配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW10]vlan batch 10 20
|
||||||
|
[SW10]int g0/0/1
|
||||||
|
[SW10-G0/0/1]port link-type access
|
||||||
|
[SW10-G0/0/1]port default vlan 10
|
||||||
|
[SW10-G0/0/1]int g0/0/2
|
||||||
|
[SW10-G0/0/2]port link-type access
|
||||||
|
[SW10-G0/0/2]port default vlan 20
|
||||||
|
[SW10-G0/0/2]quit
|
||||||
|
[SW10]port-group group-member g0/0/3 g0/0/4
|
||||||
|
[SW10-port-group]port link-type trunk
|
||||||
|
[SW10-port-group]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第三步:SW1和SW2配置VRRP负载均衡
|
||||||
|
|
||||||
|
- SW1配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]vlan batch 10 20 13
|
||||||
|
[SW1]int g0/0/1
|
||||||
|
[SW1-G0/0/1]port link-type access
|
||||||
|
[SW1-G0/0/1]port default vlan 13
|
||||||
|
[SW1-G0/0/1]quit
|
||||||
|
[SW1]int vlanif 13
|
||||||
|
[SW1-Vlanif13]ip address 192.168.13.1 24
|
||||||
|
[SW1-Vlanif13]int vlanif 10
|
||||||
|
[SW1-Vlanif10]ip address 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 vlanif 20
|
||||||
|
[SW1-Vlanif20]ip address 192.168.20.251 24
|
||||||
|
[SW1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
|
||||||
|
[SW1-Vlanif20]quit
|
||||||
|
[SW1]int g0/0/2
|
||||||
|
[SW1-G0/0/2]port link-type trunk
|
||||||
|
[SW1-G0/0/2]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW2配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]vlan batch 10 20 23
|
||||||
|
[SW2]int g0/0/1
|
||||||
|
[SW2-G0/0/1]port link-type access
|
||||||
|
[SW2-G0/0/1]port default vlan 23
|
||||||
|
[SW2-G0/0/1]quit
|
||||||
|
[SW2]int vlanif 23
|
||||||
|
[SW2-Vlanif23]ip address 192.168.23.1 24
|
||||||
|
[SW2-Vlanif23]int vlanif 10
|
||||||
|
[SW2-Vlanif10]ip address 192.168.10.252 24
|
||||||
|
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||||
|
[SW2-Vlanif10]int vlanif 20
|
||||||
|
[SW2-Vlanif20]ip address 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
|
||||||
|
[SW2-Vlanif20]quit
|
||||||
|
[SW2]int g0/0/2
|
||||||
|
[SW2-G0/0/2]port link-type trunk
|
||||||
|
[SW2-G0/0/2]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第四步:SW1/SW2/R3配置静态路由
|
||||||
|
|
||||||
|
- R1配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[R1]int g0/0/0
|
||||||
|
[R1-G0/0/0]ip address 192.168.2.254 24
|
||||||
|
[R1-G0/0/0]int g0/0/1
|
||||||
|
[R1-G0/0/1]ip address 192.168.13.3 24
|
||||||
|
[R1-G0/0/1]int g0/0/2
|
||||||
|
[R1-G0/0/2]ip address 192.168.23.3 24
|
||||||
|
[R1-G0/0/2]quit
|
||||||
|
[R1]ip route-static 192.168.10.0 24 192.168.13.1
|
||||||
|
[R1]ip route-static 192.168.10.0 24 192.168.23.1 preference 70
|
||||||
|
[R1]ip route-static 192.168.20.0 24 192.168.13.1 preference 70
|
||||||
|
[R1]ip route-static 192.168.20.0 24 192.168.23.1
|
||||||
|
```
|
||||||
|
|
||||||
|
- 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
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第五步:验证VRRP
|
||||||
|
|
||||||
|
- PC1 ping server1 验证vlan10的数据依靠SW1转发
|
||||||
|
|
||||||
|
```
|
||||||
|
PC1>tracert 192.168.2.1
|
||||||
|
1 192.168.10.251 47 ms 32 ms 46 ms
|
||||||
|
2 192.168.13.3 63 ms 62 ms 79 ms
|
||||||
|
3 192.168.2.1 62 ms 63 ms 62 ms
|
||||||
|
```
|
||||||
|
|
||||||
|
- PC2 ping server1 验证vlan20的数据依靠SW2转发
|
||||||
|
|
||||||
|
```
|
||||||
|
PC2>tracert 192.168.2.1
|
||||||
|
1 192.168.20.252 109 ms 47 ms 31 ms
|
||||||
|
2 192.168.23.3 110 ms 78 ms 78 ms
|
||||||
|
3 192.168.2.1 94 ms 78 ms 93 ms
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW1
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]display vrrp brief
|
||||||
|
VRID State Interface Type Virtual IP
|
||||||
|
----------------------------------------------------------------
|
||||||
|
10 Master Vlanif10 Normal 192.168.10.254
|
||||||
|
20 Backup Vlanif20 Normal 192.168.20.254
|
||||||
|
----------------------------------------------------------------
|
||||||
|
Total:2 Master:1 Backup:1 Non-active:0
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW2
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]display vrrp brief
|
||||||
|
VRID State Interface Type Virtual IP
|
||||||
|
----------------------------------------------------------------
|
||||||
|
10 Backup Vlanif10 Normal 192.168.10.254
|
||||||
|
20 Master Vlanif20 Normal 192.168.20.254
|
||||||
|
----------------------------------------------------------------
|
||||||
|
Total:2 Master:1 Backup:1 Non-active:0
|
||||||
|
```
|
||||||
|
|
||||||
|
### 八、VRRP+MSTP联动
|
||||||
|
|
||||||
|
![image-20240831103113797](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831103113797.png)
|
||||||
|
|
||||||
|
- **需求**
|
||||||
|
|
||||||
|
1. PC1属于vlan10 ,PC2属于vlan20
|
||||||
|
2. vlan10的主网关是SW1,备份网关是SW2,vlan10的数据流量默认由SW1转发
|
||||||
|
3. vlan20的主网关是SW2,备份网关是SW1,vlan20的数据流量默认由SW2转发
|
||||||
|
4. SW1和SW2部署MSTP和VRRP,既要实现负载分担,又要互为备份
|
||||||
|
|
||||||
|
- **配置步骤**
|
||||||
|
|
||||||
|
- 第一步:配置PC和server的IP地址,掩码,网关
|
||||||
|
|
||||||
|
- 第二步:在sw3交换机
|
||||||
|
|
||||||
|
- 创建vlan 10/20
|
||||||
|
- 与PC互联的接口,配置access模式,并加入指定的vlan
|
||||||
|
- 与交换机互联的接口配置trunk模式
|
||||||
|
- 配置MSTP
|
||||||
|
|
||||||
|
- 第三步:SW1和SW2配置VRRP和MSTP
|
||||||
|
|
||||||
|
- SW1交换机配置
|
||||||
|
|
||||||
|
1. 在SW1中创建vlan 10/20/13
|
||||||
|
2. 配置vlanif10的IP:192.168.10.251/24
|
||||||
|
3. 配置vlanif20的IP:192.168.20.251/24
|
||||||
|
4. 配置vlanif13的IP:192.168.13.1/24
|
||||||
|
5. SW1和R3互联的接口g0/0/1加入vlan13
|
||||||
|
6. SW1和SW10互联的接口配置为trunk
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. 在SW1交换机的vlanif10虚接口下,配置VRRP
|
||||||
|
2. 在vlanif10虚接口下创建备份组10的,并配置虚拟IP:192.168.10.254
|
||||||
|
3. 配置备份组10的优先级为130
|
||||||
|
4. 让SW1成为备份组10的Master-->让SW1成为vlan10的主网关
|
||||||
|
5. 在备份组10中配置上行接口跟踪,当上行接口down的时候,优先级减去50
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. 在SW1交换机的vlanif20虚接口下,配置VRRP
|
||||||
|
2. 在vlanif20虚接口下创建备份组20的,并配置虚拟IP:192.168.20.254
|
||||||
|
3. 让SW1成为备份组20的Backup-->SW1是vlan20的备份网关
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. SW1配置MSTP,让SW1成为vlan10的主根,成为vlan20的备根
|
||||||
|
|
||||||
|
- SW2交换机配置
|
||||||
|
|
||||||
|
1. 在SW2中创建vlan 10/20/23
|
||||||
|
2. 配置vlanif10的IP:192.168.10.252/24
|
||||||
|
3. 配置vlanif20的IP:192.168.20.252/24
|
||||||
|
4. 配置vlanif23的IP:192.168.23.1/24
|
||||||
|
5. SW2和R3互联的接口g0/0/1加入vlan23
|
||||||
|
6. SW2和SW10互联的接口配置为trunk
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. 在SW2交换机的vlanif10虚接口下,配置VRRP
|
||||||
|
2. 在vlanif10虚接口下创建备份组10的,并配置虚拟IP:192.168.10.254
|
||||||
|
3. 让SW2成为备份组10的Backup--SW2是vlan10的备份网关
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. 在SW2交换机的vlanif20虚接口下,配置VRRP
|
||||||
|
2. 在vlanif20虚接口下创建备份组20的,并配置虚拟IP:192.168.20.254
|
||||||
|
3. 配置备份组20的优先级为130
|
||||||
|
4. 让SW2成为备份组20的Master-->让SW2成为vlan20的主网关
|
||||||
|
5. 在备份组20中配置上行接口跟踪,当上行接口down的时候,优先级减去50
|
||||||
|
|
||||||
|
****
|
||||||
|
|
||||||
|
1. SW2配置MSTP,让SW2成为vlan20的主根,成为vlan10的备根
|
||||||
|
|
||||||
|
- 第四步:SW1/SW2/R3配置静态路由
|
||||||
|
|
||||||
|
1. 配置R3的接口IP地址
|
||||||
|
2. R3配置去往192.168.10/24 网段的路由,下一跳为SW1
|
||||||
|
3. R3配置去往192.168.10/24 网段的路由,下一跳为SW2
|
||||||
|
4. R3配置去往192.168.20/24 网段的路由,下一跳为SW1
|
||||||
|
5. R3配置去往192.168.20/24 网段的路由,下一跳为SW2
|
||||||
|
6. SW1/SW2 配置去往192.168.2.0/24网段的路由,下一跳为R3的接口IP地址
|
||||||
|
|
||||||
|
- 第五步:验证VRRP
|
||||||
|
|
||||||
|
- PC1 ping server1 验证vlan10的数据依靠SW1转发
|
||||||
|
- PC2 ping server1 验证vlan20的数据依靠SW2转发
|
||||||
|
|
||||||
|
- **配置命令**
|
||||||
|
|
||||||
|
- 第一步:配置PC和server的IP地址,掩码,网关
|
||||||
|
|
||||||
|
- 第二步:在sw3交换机
|
||||||
|
|
||||||
|
- 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
|
||||||
|
[SW3-port-group]quit
|
||||||
|
[SW3]stp region-configuration
|
||||||
|
[SW3-mst-region] region-name ntd
|
||||||
|
[SW3-mst-region] instance 10 vlan 10
|
||||||
|
[SW3-mst-region] instance 20 vlan 20
|
||||||
|
[SW3-mst-region] active region-configuration
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第三步:SW1和SW2配置VRRP和MSTP和静态路由
|
||||||
|
|
||||||
|
- SW1配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]vlan batch 10 20
|
||||||
|
[SW1]int g0/0/2
|
||||||
|
[SW1-GigabitEthernet0/0/2]port link-type trunk
|
||||||
|
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
|
||||||
|
[SW1-GigabitEthernet0/0/2]quit
|
||||||
|
[SW1]vlan batch 13
|
||||||
|
[SW1]int vlanif 10
|
||||||
|
[SW1-Vlanif10]ip address 192.168.10.251 24
|
||||||
|
[SW1-Vlanif10]int vlanif 20
|
||||||
|
[SW1-Vlanif20]ip address 192.168.20.251 24
|
||||||
|
[SW1-Vlanif20]int vlanif 13
|
||||||
|
[SW1-Vlanif13]ip address 192.168.13.1 24
|
||||||
|
[SW1-Vlanif13]quit
|
||||||
|
[SW1]int vlanif10
|
||||||
|
[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 vlanif 20
|
||||||
|
[SW1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.254
|
||||||
|
[SW1-Vlanif20]quit
|
||||||
|
[SW1]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]ip route-static 192.168.2.0 24 192.168.13.3
|
||||||
|
[SW1]stp region-configuration //配置MSTP
|
||||||
|
[SW1-mst-region]region-name ntd
|
||||||
|
[SW1-mst-region]instance 10 vlan 10
|
||||||
|
[SW1-mst-region]instance 20 vlan 20
|
||||||
|
[SW1-mst-region]active region-configuration
|
||||||
|
[SW1-mst-region]quit
|
||||||
|
[SW1]stp instance 10 priority 4096 //让SW1成为vlan10的主根
|
||||||
|
[SW1]stp instance 20 priority 8192 //让SW1成为vlan20的备根
|
||||||
|
[SW1]int g0/0/24
|
||||||
|
[SW1-GigabitEthernet0/0/24]port link-type trunk
|
||||||
|
[SW1-GigabitEthernet0/0/24]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW2的配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]vlan batch 10 20 23
|
||||||
|
[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]quit
|
||||||
|
[SW2]int vlanif 10
|
||||||
|
[SW2-Vlanif10]ip address 192.168.10.252 24
|
||||||
|
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||||
|
[SW2-Vlanif10]int vlanif20
|
||||||
|
[SW2-Vlanif20]ip address 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
|
||||||
|
[SW2-Vlanif20]quit
|
||||||
|
[SW2]int vlanif 23
|
||||||
|
[SW2-Vlanif23]ip address 192.168.23.1 24
|
||||||
|
[SW2-Vlanif23]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]ip route-static 192.168.2.0 24 192.168.23.3
|
||||||
|
[SW2]stp region-configuration
|
||||||
|
[SW2-mst-region] region-name ntd
|
||||||
|
[SW2-mst-region] instance 10 vlan 10
|
||||||
|
[SW2-mst-region] instance 20 vlan 20
|
||||||
|
[SW2-mst-region] active region-configuration
|
||||||
|
[SW2-mst-region]quit
|
||||||
|
[SW2]stp instance 10 priority 8192
|
||||||
|
[SW2]stp instance 20 priority 4096
|
||||||
|
[SW2]int g0/0/24
|
||||||
|
[SW2-GigabitEthernet0/0/24]port link-type trunk
|
||||||
|
[SW2-GigabitEthernet0/0/24]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第四步:R3配置静态路由
|
||||||
|
|
||||||
|
- R1的配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[R1]int g0/0/0
|
||||||
|
[R1-GigabitEthernet0/0/0]ip address 192.168.2.254 24
|
||||||
|
[R1-GigabitEthernet0/0/0]int g0/0/1
|
||||||
|
[R1-GigabitEthernet0/0/1]ip address 192.168.13.3 24
|
||||||
|
[R1-GigabitEthernet0/0/1]int g0/0/2
|
||||||
|
[R1-GigabitEthernet0/0/2]ip address 192.168.23.3 24
|
||||||
|
[R1-GigabitEthernet0/0/2]quit
|
||||||
|
[R1]ip route-static 192.168.10.0 24 192.168.13.1
|
||||||
|
[R1]ip route-static 192.168.10.0 24 192.168.23.1 preference 70
|
||||||
|
[R1]ip route-static 192.168.20.0 24 192.168.23.1
|
||||||
|
[R1]ip route-static 192.168.20.0 24 192.168.13.1 preference 70
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第五步:验证
|
||||||
|
|
||||||
|
- VRRPPC1 ping server1 验证连通性
|
||||||
|
- PC1 tracert server1 验证数据转发路径
|
||||||
|
- PC2 ping server1 验证连通性
|
||||||
|
- PC2 tracert server1 验证数据转发路径
|
||||||
|
|
||||||
|
> 故障模拟:断开SW1的上行链路,验证数据转发路径断开SW1的下行链路,验证数据转发路径
|
||||||
|
|
||||||
|
### 九、知识总结
|
||||||
|
|
||||||
1. **VRRP**:虚拟路由器冗余协议
|
1. **VRRP**:虚拟路由器冗余协议
|
||||||
2. **VRRP的作用**:预防单点(单网关)故障,实现网关备份
|
2. **VRRP的作用**:预防单点(单网关)故障,实现网关备份
|
||||||
|
304
B. 第二阶段/03_BFD.md
Normal file
304
B. 第二阶段/03_BFD.md
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
# BFD
|
||||||
|
|
||||||
|
### 一、BFD概述
|
||||||
|
|
||||||
|
1. Bidirectional Forwarding Detection
|
||||||
|
|
||||||
|
> 双向转发检测
|
||||||
|
|
||||||
|
2. BFD技术背景
|
||||||
|
|
||||||
|
1. 现网中存在的问题
|
||||||
|
- 不能快速有效的发现网络设备或链路出现的故障
|
||||||
|
- 不能以毫秒级的速度发现网络问题
|
||||||
|
- 协议自身的报文检测机制一般都大于1秒
|
||||||
|
2. 解决方案:
|
||||||
|
- 需要一种专门用于快速检测设备或链路的协议:BFD协议产生
|
||||||
|
|
||||||
|
3. BFD的作用
|
||||||
|
|
||||||
|
- 专门用于发送超小和超快的检测数据包,以毫秒级进行发送,快速检测链路的故障,改善网络性能
|
||||||
|
- 当发现链路故障时,通知相关的设备和协议进行处理,快速恢复通信,保证网络可靠性
|
||||||
|
|
||||||
|
4. BFD的优点
|
||||||
|
|
||||||
|
- 对任何介质、任何协议层进行实时且快速的检测
|
||||||
|
|
||||||
|
5. BFD会话建立方式
|
||||||
|
|
||||||
|
- BFD会话的建立有:静态建立、动态建立两种方式
|
||||||
|
- 静态建立BFD会话:手工配置BFD会话参数(手工配置:本地标识符和远端标识符)
|
||||||
|
- 动态建立BFD会话:动态分配本地标识符、自学习远端标识符
|
||||||
|
- 静态和动态的主要区别:本地标识符和远端标识符配置方式不同
|
||||||
|
|
||||||
|
6. BFD检测机制
|
||||||
|
|
||||||
|
- 两个设备建立BFD会话,链路两端周期性发送BFD控制报文,如果一端在既定的时间内没有收到BFD控制报文,则认为路径上发生了故障。
|
||||||
|
|
||||||
|
7. BFD会话常见参数的缺省配置
|
||||||
|
|
||||||
|
| 参数 | 缺省值 |
|
||||||
|
| ------------ | -------- |
|
||||||
|
| 发送间隔 | 1000毫秒 |
|
||||||
|
| 接收间隔 | 1000毫秒 |
|
||||||
|
| 本地检测倍数 | 3 |
|
||||||
|
|
||||||
|
### 二、BFD和静态路由联动
|
||||||
|
|
||||||
|
![image-20240831104707266](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831104707266.png)
|
||||||
|
|
||||||
|
- **需求**
|
||||||
|
|
||||||
|
- 实现PC1 和PC2的互联互通
|
||||||
|
- 实现BFD和静态路由联动
|
||||||
|
|
||||||
|
- **配置步骤**
|
||||||
|
|
||||||
|
1. 配置PC的IP地址,掩码,网关
|
||||||
|
2. 配置路由器的接口IP地址
|
||||||
|
3. 配置静态路由和浮动路由
|
||||||
|
4. 配置BFD
|
||||||
|
5. 配置BFD和静态路由联动
|
||||||
|
6. 验证与测试
|
||||||
|
|
||||||
|
- **配置命令**
|
||||||
|
|
||||||
|
- 第一步:配置PC的接口IP地址
|
||||||
|
|
||||||
|
- 第二步:配置路由器的接口IP地址
|
||||||
|
|
||||||
|
- 第三步:配置静态路由和浮动路由
|
||||||
|
|
||||||
|
- R1配置浮动路由
|
||||||
|
|
||||||
|
```
|
||||||
|
[R1]ip route-static 192.168.2.0 24 192.168.12.2 :主路由
|
||||||
|
[R1]ip route-static 192.168.2.0 24 192.168.13.3 preference 70 :浮动路由
|
||||||
|
```
|
||||||
|
|
||||||
|
> R1去往24.0网段,要做BFD[R1]ip route-static 192.168.24.0 24 192.168.12.2
|
||||||
|
|
||||||
|
- R2配置静态路由
|
||||||
|
|
||||||
|
```
|
||||||
|
[R2]ip route-static 192.168.1.0 24 192.168.12.1
|
||||||
|
[R2]ip route-static 192.168.2.0 24 192.168.24.4
|
||||||
|
```
|
||||||
|
|
||||||
|
- R3配置静态路由
|
||||||
|
|
||||||
|
```
|
||||||
|
[R3]ip route-static 192.168.1.0 24 192.168.13.1
|
||||||
|
[R3]ip route-static 192.168.2.0 24 192.168.34.4
|
||||||
|
```
|
||||||
|
|
||||||
|
- R4配置浮动路由
|
||||||
|
|
||||||
|
```
|
||||||
|
[R4]ip route-static 192.168.1.0 24 192.168.24.2
|
||||||
|
[R4]ip route-static 192.168.1.0 24 192.168.34.3 preference 70
|
||||||
|
```
|
||||||
|
|
||||||
|
> R4去往12.0网段,要做BFD[R4]ip route-static 192.168.12.0 24 192.168.24.2
|
||||||
|
|
||||||
|
- 第四步:配置BFD
|
||||||
|
|
||||||
|
- R1的配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[R1]bfd
|
||||||
|
[R1-bfd]quit
|
||||||
|
[R1]bfd ntd bind peer-ip 192.168.24.4
|
||||||
|
[R1-bfd-session-ntd]discriminator local 1
|
||||||
|
[R1-bfd-session-ntd]discriminator remote 4
|
||||||
|
[R1-bfd-session-ntd]min-tx-interval 10
|
||||||
|
[R1-bfd-session-ntd]min-rx-interval 10
|
||||||
|
[R1-bfd-session-ntd]commit
|
||||||
|
[R1-bfd-session-ntd]quit
|
||||||
|
```
|
||||||
|
|
||||||
|
- R4的配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[R4]bfd
|
||||||
|
[R4-bfd]quit
|
||||||
|
[R4]bfd ntd bind peer-ip 192.168.12.1
|
||||||
|
[R4-bfd-session-ntd]discriminator local 4
|
||||||
|
[R4-bfd-session-ntd]discriminator remote 1
|
||||||
|
[R4-bfd-session-ntd]min-tx-interval 10
|
||||||
|
[R4-bfd-session-ntd]min-rx-interval 10
|
||||||
|
[R4-bfd-session-ntd]commit
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第五步:配置BFD和静态路由联动
|
||||||
|
|
||||||
|
- R1
|
||||||
|
|
||||||
|
```
|
||||||
|
[R1]ip route-static 192.168.2.0 24 192.168.12.2 track bfd-session ntd2308
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第六步:验证与测试
|
||||||
|
|
||||||
|
- R1
|
||||||
|
|
||||||
|
```
|
||||||
|
<R1>display bfd session all
|
||||||
|
```
|
||||||
|
|
||||||
|
> 将R2和R4之间的链路断开,验证浮动路由是否切换
|
||||||
|
>
|
||||||
|
> 确保PC1和PC2能够正常通信,不因链路中断,而导致网络不可达
|
||||||
|
|
||||||
|
### 三、VRRP和BFD联动实验
|
||||||
|
|
||||||
|
![image-20240831110337612](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831110337612.png)
|
||||||
|
|
||||||
|
- **需求**
|
||||||
|
|
||||||
|
- 部署VRRP,让SW1成为备份组10的-Master设备(vlan10的主网关)
|
||||||
|
- 让SW2成为备份组10的-Backup设备(vlan10的备份网关)
|
||||||
|
- 部署VRRP和BFD联动可以解决的问题:
|
||||||
|
- 在VRRP中当SW1-主网关,出现故障的时候,备份网关SW2需要等待3秒后,才可以升级为新的主网关,承担流量转发任务。
|
||||||
|
- 3秒对有些企业网络来说是不可以接受的,我们需要实现VRRP主备设备更加快速的切换(毫秒级故障切换)
|
||||||
|
|
||||||
|
- **解决方案**
|
||||||
|
|
||||||
|
- 在运行VRRP网络设备上(SW1/SW2)运行BFD协议
|
||||||
|
- 在SW1和SW2之间建立BFD会话,通过BFD协议快速检测和感知设备或链路故障
|
||||||
|
- 在SW2中配置VRRP和BFD联动,当SW1-主网关出现故障的时候,BFD会话会Down
|
||||||
|
- 此时BFD协议会通知备份网关SW2,立即将VRRP优先级调高,已实现SW2快速成为主网关
|
||||||
|
|
||||||
|
- **配置步骤**
|
||||||
|
|
||||||
|
- 第一步:配置PC的IP地址,掩码,网关
|
||||||
|
- 第二步:配置sw3交换机的vlan,端口加vlan 配trunk
|
||||||
|
- 第三步:SW1和SW2配置vrrp-热备
|
||||||
|
1. 创建vlan
|
||||||
|
2. 配置vlanif接口地址
|
||||||
|
3. 配置vrrp 备份组,配置虚拟IP
|
||||||
|
4. 配置优先级
|
||||||
|
5. 交换机互联接口配置trunk
|
||||||
|
- 第四步:配置SW1和SW2的BFD会话
|
||||||
|
1. 开启BFD功能
|
||||||
|
2. 创建BFD会话
|
||||||
|
3. 配置本地标识符
|
||||||
|
4. 配置远端标识符
|
||||||
|
5. 提交
|
||||||
|
- 第五步:配置VRRP和BFD联动
|
||||||
|
- 配置VRRP和BFD联动,跟踪BFD会话,一旦发现BFD会话down掉,SW2的VRRP的优先级会在原来的基础上增加60,让SW2快速的成为Master设备
|
||||||
|
- 第六步:模拟故障,验证BFD
|
||||||
|
|
||||||
|
- **配置命令**
|
||||||
|
|
||||||
|
- 第一步:配置PC的IP地址,掩码,网关
|
||||||
|
|
||||||
|
- 第二步:配置sw3交换机的vlan,端口加vlan 配trunk
|
||||||
|
|
||||||
|
- SW3配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW3]vlan 10
|
||||||
|
[SW3-vlan10]quit
|
||||||
|
[SW3]port-group group-member g0/0/1 g0/0/2
|
||||||
|
[SW3-port-group]port link-type access
|
||||||
|
[SW3-port-group]port default vlan 10
|
||||||
|
[SW3-port-group]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和SW2配置vrrp-热备
|
||||||
|
|
||||||
|
- SW1配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]vlan 10
|
||||||
|
[SW1-vlan10]quit
|
||||||
|
[SW1]int g0/0/1
|
||||||
|
[SW1-G0/0/1]port link-type trunk
|
||||||
|
[SW1-G0/0/1]port trunk allow-pass vlan all
|
||||||
|
[SW1-G0/0/1]quit
|
||||||
|
[SW1]int vlanif 10
|
||||||
|
[SW1-Vlanif10]ip address 192.168.10.251 24
|
||||||
|
[SW1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||||
|
[SW1-Vlanif10]vrrp vrid 10 priority 130
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW2配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]vlan 10
|
||||||
|
[SW2-vlan10]quit
|
||||||
|
[SW2]int 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]quit
|
||||||
|
[SW2]int vlanif 10
|
||||||
|
[SW2-Vlanif10]ip address 192.168.10.252 24
|
||||||
|
[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.254
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第四步:配置SW1和SW2的BFD会话
|
||||||
|
|
||||||
|
- SW1配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]bfd //开启BFD功能
|
||||||
|
[SW1-bfd]quit //退出
|
||||||
|
[SW1]bfd tedu bind peer-ip 192.168.10.252 //在系统视图下创建BFD会话,绑定对端IP地址
|
||||||
|
[SW1-bfd-session-tedu]discriminator local 1 //配置本地标识符
|
||||||
|
[SW1-bfd-session-tedu]discriminator remote 2 //配置远端标识符
|
||||||
|
[SW1-bfd-session-tedu]min-rx-interval 100 //配置接收报文间隔时间(100毫秒)
|
||||||
|
[SW1-bfd-session-tedu]min-tx-interval 100 //配置发送报文间隔时间(100毫秒)
|
||||||
|
[SW1-bfd-session-tedu]commit //提交
|
||||||
|
```
|
||||||
|
|
||||||
|
- SW2
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]bfd //开启BFD功能
|
||||||
|
[SW2-bfd]quit
|
||||||
|
[SW2]bfd tedu bind peer-ip 192.168.10.251 //创建BFD会话,绑定对端IP地址
|
||||||
|
[SW2-bfd-session-tedu]discriminator local 2 //本地标识符为2
|
||||||
|
[SW2-bfd-session-tedu]discriminator remote 1 //远端标识符为1
|
||||||
|
[SW2-bfd-session-tedu]min-rx-interval 100 //接受报文间隔时间100毫秒
|
||||||
|
[SW2-bfd-session-tedu]min-tx-interval 100 //发送报文间隔时间100毫秒
|
||||||
|
[SW2-bfd-session-tedu]commit //提交
|
||||||
|
```
|
||||||
|
|
||||||
|
- 第五步:在SW2上配置VRRP和BFD联动
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]int vlanif 10
|
||||||
|
[SW2-Vlanif10]vrrp vrid 10 track bfd-session 2 increased 60
|
||||||
|
```
|
||||||
|
|
||||||
|
> 配置VRRP和BFD联动,跟踪BFD会话,一旦发现BFD会话down掉,就让SW2的VRRP的优先级在原来的基础上增加60,让SW2快速的成为Master设备
|
||||||
|
|
||||||
|
- 第六步:模拟SW1故障,在SW2中验证BFD和VRRP联动
|
||||||
|
|
||||||
|
- SW2
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]display vrrp
|
||||||
|
Vlanif10 | Virtual Router 10
|
||||||
|
State : Master
|
||||||
|
Virtual IP : 192.168.10.254
|
||||||
|
Master IP : 192.168.10.252
|
||||||
|
PriorityRun : 160
|
||||||
|
PriorityConfig : 100
|
||||||
|
MasterPriority : 160
|
||||||
|
Preempt : YES Delay Time : 0 s
|
||||||
|
TimerRun : 1 s
|
||||||
|
TimerConfig : 1 s
|
||||||
|
Auth type : NONE
|
||||||
|
Virtual MAC : 0000-5e00-010a
|
||||||
|
Check TTL : YES
|
||||||
|
Config type : normal-vrrp
|
||||||
|
Track BFD : 2 Priority increased : 60 BFD-session state : DOWN // 重点看这条
|
||||||
|
Create time : 2022-12-29 17:32:15 UTC-08:00
|
||||||
|
Last change time : 2022-12-29 17:50:00 UTC-08:00
|
||||||
|
```
|
||||||
|
|
381
B. 第二阶段/04_子网划分.md
Normal file
381
B. 第二阶段/04_子网划分.md
Normal file
@ -0,0 +1,381 @@
|
|||||||
|
# 子网划分
|
||||||
|
|
||||||
|
### 一、子网划分概述
|
||||||
|
|
||||||
|
1. **子网划分是什么**
|
||||||
|
- 子网划分是指将一个大的网段划分多个更小的网段
|
||||||
|
2. **子网划分的作用**
|
||||||
|
- 节约IPv4地址,减少IPv4地址浪费
|
||||||
|
3. **如何进行子网划分**
|
||||||
|
- 将主机位借给网络位 (让主机位变短, 让网络位变长)
|
||||||
|
|
||||||
|
### 二、IP地址知识回顾
|
||||||
|
|
||||||
|
1. **IPv4地址的长度**:32个bit位
|
||||||
|
|
||||||
|
**IPv4的组成**:网络位+主机位
|
||||||
|
|
||||||
|
**子网掩码长度**:32个bit位
|
||||||
|
|
||||||
|
**C类的默认子网掩码**:255.255.255.0
|
||||||
|
|
||||||
|
**一个C类网段有多少个IP地址,有多少个可用IP地址如何计算**:
|
||||||
|
|
||||||
|
举例:192.168.1.0/24
|
||||||
|
|
||||||
|
IP网段: 192.168.1.0
|
||||||
|
|
||||||
|
子网掩码:255.255.255.0
|
||||||
|
|
||||||
|
以二进制显示:192.168.1.0/24
|
||||||
|
|
||||||
|
| IP网段(十进制) | 192 | 168 | 1 | 0 |
|
||||||
|
| ------------------ | -------- | -------- | -------- | ------------ |
|
||||||
|
| 二进制显示 | 11000000 | 10101000 | 00000001 | 00000000 |
|
||||||
|
| 子网掩码(十进制) | 255 | 255 | 255 | 0 |
|
||||||
|
| 二进制显示 | 11111111 | 11111111 | 11111111 | **00000000** |
|
||||||
|
| | 网络位 | | | 主机位 |
|
||||||
|
|
||||||
|
2. 一个C类网段有多少IP地址
|
||||||
|
|
||||||
|
> 2的8次方=256个IP地址
|
||||||
|
|
||||||
|
3. 为什么是2的8次方呢?
|
||||||
|
|
||||||
|
> 因为子网掩码中主机位有8位(8个0) ,所以一个C类网段的有256个IP地址
|
||||||
|
|
||||||
|
4. 一个C类网段有多少可用IP地址数量
|
||||||
|
|
||||||
|
> 2的8次方-2等于254个IP地址
|
||||||
|
|
||||||
|
5. 为什么要减2呢?
|
||||||
|
|
||||||
|
> 因为要减去一个网络ID,减去一个广播地址
|
||||||
|
>
|
||||||
|
> 网络ID :192.168.1.0
|
||||||
|
>
|
||||||
|
> 广播地址: 192.168.1.255
|
||||||
|
|
||||||
|
6. 一个C类网段有256个地址,一个部门只有50台电脑,所以有点浪费,做子网划分如何做子网划分呢?
|
||||||
|
|
||||||
|
> IP地址和子网掩码长度:都是32bit,是固定的网络位越长,主机位越短,主机位越短,包含的IP地址就越少
|
||||||
|
|
||||||
|
- 举例:
|
||||||
|
- 掩码16位:255.255.0.0 (65536个IP地址)
|
||||||
|
- 掩码24位:255.255.255.0 (256个IP地址)
|
||||||
|
|
||||||
|
> 所以:主机位越短,就代表,这个网段包含的IP地址数量越少
|
||||||
|
>
|
||||||
|
> 所以:想要做子网划分,就从主机位借位,借给网络位,让网络位变长,让主机位变短
|
||||||
|
|
||||||
|
### 三、子网划分方法
|
||||||
|
|
||||||
|
- 举例:192.168.1.0/24 要做子网划分
|
||||||
|
|
||||||
|
1. 网络位 主机位
|
||||||
|
|
||||||
|
IP网段: 192. 168. 1. 0
|
||||||
|
|
||||||
|
二进制: 11000000.10101000.00000001. 00000000 /24
|
||||||
|
|
||||||
|
子网掩码: 255. 255. 255. 0
|
||||||
|
|
||||||
|
二进制: 11111111.11111111.11111111. 00000000 /24
|
||||||
|
|
||||||
|
子网划分: 11000000.10101000.00000001. 0 0000000 /25
|
||||||
|
|
||||||
|
网络位 子网位 主
|
||||||
|
|
||||||
|
> 备注:
|
||||||
|
>
|
||||||
|
> 将主机位中的1个二进制位借给网络位,
|
||||||
|
>
|
||||||
|
> 借完后:网络位增加了1个二进制位,所以网络位就变成了24+1==25位
|
||||||
|
>
|
||||||
|
> 借完后:主机位减少了1个二进制位,所以主机位就变成了8-1 ==7位
|
||||||
|
|
||||||
|
```
|
||||||
|
1个二进制数有2个变化,一个是0, 一个是1 ,所以子网网络位如果为1位的话,可以划分2个子网网段如果主机位借了一位给网络位,还剩7个主机位,2的7次方=128所以如果主机位借了一位给网络位,那么可以划分2个子网网段,每个子网网段有128个IP地址
|
||||||
|
每个子网网段有128-2=126个可用IP地址
|
||||||
|
子网划分: 借1位,可以拥有2个网段:
|
||||||
|
第一个网段:192.168.1.0/25
|
||||||
|
11000000.10101000.00000001. 0 0000000 /25
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ ----------
|
||||||
|
```
|
||||||
|
网络位 子网位 主
|
||||||
|
最小: 11000000.10101000.00000001. 0 0000000/25 (192.168.1.0)
|
||||||
|
最大: 11000000.10101000.00000001. 0 1111111/25 (192.168.1.127)
|
||||||
|
转换成十进制:(最小)192.168.1.0----192.168.1.127(最大)
|
||||||
|
第一个网段的取值范围:192.168.1.0----192.168.1.127
|
||||||
|
网络ID: 192.168.1.0
|
||||||
|
子网掩码: 25
|
||||||
|
第一个可用IP: 192.168.1.1
|
||||||
|
最后一个可用IP: 192.168.1.126
|
||||||
|
广播地址: 192.168.1.127
|
||||||
|
IP地址数量: 128
|
||||||
|
可用IP地址数量:126
|
||||||
|
第二个网段:192.168.1.128/25 11000000.10101000.00000001. 1 0000000 /25
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ ----------
|
||||||
|
```
|
||||||
|
网络位 子网位 主
|
||||||
|
最小: 11000000.10101000.00000001. 1 0000000/25 (192.168.1.128)
|
||||||
|
最大: 11000000.10101000.00000001. 1 1111111/25 (192.168.1.255)
|
||||||
|
转换成十进制:(最小)192.168.1.128----192.168.1.255(最大) 第二个网段的取值范围:192.168.1.128----192.168.1.255
|
||||||
|
网络ID: 192.168.1.128
|
||||||
|
子网掩码: 25
|
||||||
|
第一个可用IP: 192.168.1.129
|
||||||
|
最后一个可用IP: 192.168.1.254
|
||||||
|
广播地址: 192.168.1.255
|
||||||
|
IP地址数量: 128
|
||||||
|
可用IP地址数量:126
|
||||||
|
备注:掩码25等于多少
|
||||||
|
掩码25:11111111.11111111.11111111. 1 0000000
|
||||||
|
掩码25:255.255.255.128
|
||||||
|
那么如果,主机位借了2位给网络位呢,可以划分多少个子网网段,每个子网网段有多少个IP地址
|
||||||
|
将主机位中的2个二进制位借给网络位,
|
||||||
|
借完后:网络位增加了2个二进制位,所以网络位就变成了24+2==26位
|
||||||
|
借完后:主机位减少了2个二进制位,所以主机位就变成了8-2 ==6位
|
||||||
|
子网位为2,可以划分4个网段:因为2的2次方等于4
|
||||||
|
如果主机位借了2位给网络位,还剩6个主机位,2的6次方=64
|
||||||
|
所以如果主机位借了2位给网络位,那么可以划分4个子网网段,每个网段有64个IP地址
|
||||||
|
子网计算公式:
|
||||||
|
子网数=2的n次方 (n代表的子网位数)
|
||||||
|
主机数=2的N次方-2 (N代表主机位数)(主机数:表示的是可用IP地址)
|
||||||
|
第一个网段:192.168.1.0/26
|
||||||
|
11000000.10101000.00000001. 00 000000 /26
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ --------
|
||||||
|
```
|
||||||
|
网络位 子网位 主
|
||||||
|
最小: 11000000.10101000.00000001. 00 000000/26 (192.168.1.0)
|
||||||
|
最大: 11000000.10101000.00000001. 00 111111/26 (192.168.1.63)
|
||||||
|
第一个网段的取值范围:192.168.1.0----192.168.1.63
|
||||||
|
网络ID: 192.168.1.0
|
||||||
|
子网掩码: 26
|
||||||
|
第一个可用IP: 192.168.1.1
|
||||||
|
最后一个可用IP: 192.168.1.62
|
||||||
|
广播地址: 192.168.1.63
|
||||||
|
IP地址数量: 64
|
||||||
|
可用IP地址数量:62
|
||||||
|
第二个网段: 192.168.1.64/26
|
||||||
|
11000000.10101000.00000001. 01 000000 /26
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ --------
|
||||||
|
```
|
||||||
|
网络位 子网位 主
|
||||||
|
最小: 11000000.10101000.00000001. 01 000000/26 (192.168.1.64)
|
||||||
|
最大: 11000000.10101000.00000001. 01 111111/26 (192.168.1.127)
|
||||||
|
第二个网段的取值范围:192.168.1.64-192.168.1.127
|
||||||
|
网络ID: 192.168.1.64
|
||||||
|
子网掩码: 26
|
||||||
|
第一个可用IP: 192.168.1.65
|
||||||
|
最后一个可用IP: 192.168.1.126
|
||||||
|
广播地址: 192.168.1.127
|
||||||
|
IP地址数量: 64
|
||||||
|
可用IP地址数量:62
|
||||||
|
第三个网段:192.168.1.128/26
|
||||||
|
11000000.10101000.00000001. 10 0000000 /26
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ ----------
|
||||||
|
```
|
||||||
|
网络位 子网网络位 主
|
||||||
|
最小: 11000000.10101000.00000001. 10 000000/26 (192.168.1.128)
|
||||||
|
最大: 11000000.10101000.00000001. 10 111111/26 (192.168.1.191)
|
||||||
|
第三个网段的取值范围:192.168.1.128-192.168.1.191
|
||||||
|
网络ID: 192.168.1.128
|
||||||
|
子网掩码: 26
|
||||||
|
第一个可用IP: 192.168.1.129
|
||||||
|
最后一个可用IP: 192.168.1.190
|
||||||
|
广播地址: 192.168.1.191
|
||||||
|
IP地址数量: 64
|
||||||
|
可用IP地址数量:62
|
||||||
|
第四个网段:192.168.1.192/26
|
||||||
|
11000000.10101000.00000001. 11 0000000 /26
|
||||||
|
```
|
||||||
|
|
||||||
|
-------------------------- ------ ----------
|
||||||
|
```
|
||||||
|
网络位 子网网络位 主
|
||||||
|
最小: 11000000.10101000.00000001. 11 000000/26 (192.168.1.192)
|
||||||
|
最大: 11000000.10101000.00000001. 11 111111/26 (192.168.1.255)
|
||||||
|
第四个网段的取值范围:192.168.1.192-192.168.1.255
|
||||||
|
网络ID: 192.168.1.192
|
||||||
|
子网掩码: 26
|
||||||
|
第一个可用IP: 192.168.1.193
|
||||||
|
最后一个可用IP: 192.168.1.254
|
||||||
|
广播地址: 192.168.1.255
|
||||||
|
IP地址数量: 64
|
||||||
|
可用IP地址数量:62
|
||||||
|
备注:掩码26等于多少
|
||||||
|
掩码26:11111111.11111111.11111111.11000000
|
||||||
|
掩码26:255.255.255.192
|
||||||
|
```
|
||||||
|
|
||||||
|
### 四、等长子网划分实验
|
||||||
|
|
||||||
|
1. **需求**
|
||||||
|
|
||||||
|
- 目前公司只有1个C类网段:192.168.100.0/24
|
||||||
|
- 某公司有销售部、生成部、财务部、客服部四个部门
|
||||||
|
- 每个部门的主机数量不超过50台
|
||||||
|
|
||||||
|
2. **解决方案:执行等长的子网划分**
|
||||||
|
|
||||||
|
- 划分4个相同大小的子网网段
|
||||||
|
- 每个子网网段中的IP地址数量相同
|
||||||
|
|
||||||
|
3. **子网划分分析**
|
||||||
|
|
||||||
|
公司有4个部门,需要划分4个网段,每个网段不低于50个IP地址
|
||||||
|
|
||||||
|
- *思考1:*
|
||||||
|
|
||||||
|
一个C类网段,默认网络位24位,主机位为8位
|
||||||
|
|
||||||
|
如果想一个C类网段要划分4个子网网段:网络位要从主机位借几位?
|
||||||
|
|
||||||
|
2的2次方等于4,如果想要划分4个子网,需要从主机位借2位,做子网网络位
|
||||||
|
|
||||||
|
我们借2位,掩码为/26
|
||||||
|
|
||||||
|
- *思考2:*
|
||||||
|
|
||||||
|
一个C类网段,默认网络位24位,主机位为8位
|
||||||
|
|
||||||
|
如果我们借2位,网络位为26位,那么主机位为6位
|
||||||
|
|
||||||
|
主机数量=2的N次方-2
|
||||||
|
|
||||||
|
所以:2的6次方-2等于62 (可用IP地址为62 )
|
||||||
|
|
||||||
|
公司四个部门,每个部门不超过50台主机,所以可以满足公司需求
|
||||||
|
|
||||||
|
划分结果:分配4个子网网段,掩码为26
|
||||||
|
|
||||||
|
192.168.100.0/26 (第一个子网网段)
|
||||||
|
|
||||||
|
192.168.100.64/26 (第二个子网网段)
|
||||||
|
|
||||||
|
192.168.100.128/26 (第三个子网网段)
|
||||||
|
|
||||||
|
192.168.100.192/26 (第四个子网网段)
|
||||||
|
备注:掩码26等于多少
|
||||||
|
掩码26:11111111.11111111.11111111.11000000
|
||||||
|
掩码26:255.255.255.192
|
||||||
|
备注:掩码25等于多少
|
||||||
|
掩码26:11111111.11111111.11111111.10000000
|
||||||
|
掩码26:255.255.255.128
|
||||||
|
|
||||||
|
![image-20240831115149980](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831115149980.png)
|
||||||
|
|
||||||
|
- **拓扑**
|
||||||
|
|
||||||
|
![image-20240831115220751](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/image-20240831115220751.png)
|
||||||
|
|
||||||
|
- **需求**
|
||||||
|
|
||||||
|
- 将192.168.100.0/24做子网划分,分配4个等长的子网,分给4个部门使用
|
||||||
|
- vlan内的主机通过dhcp获取IP地址
|
||||||
|
|
||||||
|
- **配置命令**
|
||||||
|
|
||||||
|
- VLAN
|
||||||
|
|
||||||
|
- SW2的配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW2]int g0/0/2
|
||||||
|
[SW2-G0/0/2]port link-type access
|
||||||
|
[SW2-G0/0/2]port default vlan 10
|
||||||
|
[SW2-G0/0/2]int g0/0/3
|
||||||
|
[SW2-G0/0/3]port link-type access
|
||||||
|
[SW2-G0/0/3]port default vlan 20
|
||||||
|
[SW2-G0/0/3]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 30 40
|
||||||
|
[SW3]int g0/0/2
|
||||||
|
[SW3-G0/0/2]port link-type access
|
||||||
|
[SW3-G0/0/2]port default vlan 30
|
||||||
|
[SW3-G0/0/2]int g0/0/3
|
||||||
|
[SW3-G0/0/3]port link-type access
|
||||||
|
[SW3-G0/0/3]port default vlan 40
|
||||||
|
[SW3-G0/0/3]int g0/0/1
|
||||||
|
[SW3-G0/0/1]port link-type trunk
|
||||||
|
[SW3-G0/0/1]port trunk allow-pass vlan all
|
||||||
|
```
|
||||||
|
|
||||||
|
- DHCP
|
||||||
|
|
||||||
|
- SW1-DHCP的基础配置
|
||||||
|
|
||||||
|
```
|
||||||
|
[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-DHCP配置IP地址池
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]dhcp enable
|
||||||
|
[SW1]ip pool vlan10
|
||||||
|
[SW1-ip-pool-vlan10]network 192.168.100.0 mask 26
|
||||||
|
[SW1-ip-pool-vlan10]gateway-list 192.168.100.62
|
||||||
|
[SW1-ip-pool-vlan10]dns-list 8.8.8.8
|
||||||
|
[SW1-ip-pool-vlan10]ip pool vlan20
|
||||||
|
[SW1-ip-pool-vlan20]network 192.168.100.64 mask 26
|
||||||
|
[SW1-ip-pool-vlan20]gateway-list 192.168.100.126
|
||||||
|
[SW1-ip-pool-vlan20]dns-list 8.8.8.8
|
||||||
|
[SW1-ip-pool-vlan20]ip pool vlan30
|
||||||
|
[SW1-ip-pool-vlan30]network 192.168.100.128 mask 26
|
||||||
|
[SW1-ip-pool-vlan30]gateway-list 192.168.100.190
|
||||||
|
[SW1-ip-pool-vlan30]dns-list 8.8.8.8
|
||||||
|
[SW1-ip-pool-vlan30]ip pool vlan40
|
||||||
|
[SW1-ip-pool-vlan40]network 192.168.100.192 mask 26
|
||||||
|
[SW1-ip-pool-vlan40]gateway-list 192.168.100.254
|
||||||
|
[SW1-ip-pool-vlan40]dns-list 8.8.8.8
|
||||||
|
```
|
||||||
|
|
||||||
|
- 在接口下开启基于全局的dhcp
|
||||||
|
|
||||||
|
- SW1
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]int vlan 10
|
||||||
|
[SW1-Vlanif10]ip add 192.168.100.62 26
|
||||||
|
[SW1-Vlanif10]dhcp select global
|
||||||
|
[SW1-Vlanif10]int vlan 20
|
||||||
|
[SW1-Vlanif20]ip add 192.168.100.126 26
|
||||||
|
[SW1-Vlanif20]dhcp select global
|
||||||
|
[SW1-Vlanif20]int vlan 30
|
||||||
|
[SW1-Vlanif30]ip add 192.168.100.190 26
|
||||||
|
[SW1-Vlanif30]dhcp select global
|
||||||
|
[SW1-Vlanif30]int vlan 40
|
||||||
|
[SW1-Vlanif40]ip add 192.168.100.254 26
|
||||||
|
[SW1-Vlanif40]dhcp select global
|
||||||
|
```
|
||||||
|
|
||||||
|
- 验证:所有的PC都获取到IP地址
|
||||||
|
|
||||||
|
- SW1
|
||||||
|
|
||||||
|
```
|
||||||
|
[SW1]display ip pool name vlan10 used
|
||||||
|
```
|
||||||
|
|
||||||
|
### 五、子网划分分类
|
||||||
|
|
@ -85,5 +85,11 @@
|
|||||||
round-trip min/avg/max = 31/50/63 ms
|
round-trip min/avg/max = 31/50/63 ms
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
*预习*
|
||||||
|
|
||||||
|
![屏幕截图 2024-08-30 180528](https://picgo-noriu.oss-cn-beijing.aliyuncs.com/Images/%E5%B1%8F%E5%B9%95%E6%88%AA%E5%9B%BE%202024-08-30%20180528.png)
|
||||||
|
Loading…
Reference in New Issue
Block a user