Top

  1. 端口隔离 综合案例
  2. 配置静态路由
  3. 配置默认路由
  4. VLAN 间通信之单臂路由
  5. 路由网综合案例

1 端口隔离 综合案例

1.1 问题

1)PC1/2/3/4 都属于同一个 VLAN 100

2)IP 地址所在网段为 192.168.100.0/24,网关地址为 192.168.100.254

3)PC1/2 不能互相访问,但是都可以访问 PC3/4

4)同时,所有的 PC 都可以访问 Server1

1.2 方案

使用 eNSP 搭建实验环境,如图 - 1 所示。

CASE - 图1

图 - 1

1.3 步骤

实现此案例需要按照如下步骤进行。

1)如图配置 PC 、R1、Server1 的 IP 地址和网关

2)在 SW1 上配置端口隔离

  1. 1. vlan 100
  2. 2. quit
  3. 4. port-group group-member gi0/0/1 to gi0/0/5
  4. 5. port link access
  5. 6. port default vlan 100
  6. 7. quit
  7. 9. port-group group-member gi0/0/1 gi0/0/2
  8. 10. port-isolate enable group 1 -> 开启端口隔离,并加入组1
  9. 11. quit

3)测试 PC 与 Server1 之间的连通性

2 配置静态路由

2.1 问题

1)如图互联设备,配置接口 IP 地址

2)配置静态路由,确保 PC 之间互通

2.2 方案

使用 eNSP 搭建实验环境,如图 - 2 所示。

/

图 - 2

2.3 步骤

实现此案例需要按照如下步骤进行。

1)如图配置 PC 、R1、Server1 的 IP 地址和网关

2)在 R1/R2 上配置去往对端 PC 的静态路由

  1. 1. \[R1\]ip route-static 192.168.4.0 24 192.168.2.2
  2. 2. \[R2\]ip route-static 1921.68.1.0 24 192.168.2.1

3)测试 PC1 与 PC2 之间的连通性

3 配置默认路由

3.1 问题

配置设备的接口 IP 地址,并通过配置静态路由和默认路由,实现全网设备互通

3.2 方案

使用 eNSP 搭建实验环境,如图 - 3 所示。

CASE - 图2

图 - 3

3.3 步骤

实现此案例需要按照如下步骤进行。

  1. 配置 PC 的 IP 地址和网关
  2. 保持交换机 SW1/2 的默认配置不变
  3. 配置 R1/R2/R3 的接口 IP 地址
  4. 配置 R1/R2/R3 的路由条目
  1. 1. \[R1\] ip route-static 0.0.0.0 0 192.168.2.2
  2. 2. \[R2\] ip route-static 192.168.1.0 24 192.168.2.1
  3. 3. \[R2\] ip route-static 192.168.4.0 24 192.168.3.2
  4. 4. \[R3\] ip route-static 0.0.0.0 0 192.168.3.1
  1. 测试 PC1 和 PC2 之间的连通性

4 VLAN 间通信之单臂路由

4.1 问题

1)如图配置 PC 和路由器的接口 IP 地址

2)在 R1 上配置单臂路由,实现 PC1/2 之间的互通

4.2 方案

使用 eNSP 搭建实验环境,如图 - 4 所示。

CASE - 图3

图 - 4

4.3 步骤

实现此案例需要按照如下步骤进行。

步骤一:配置交换机

  1. 1. \[SW1\]vlan batch 10 20
  2. 3. \[SW1\]interface eth0/0/1
  3. 4. \[SW1-Ethernet0/0/1\]port link-type access
  4. 5. \[SW1-Ethernet0/0/1\]port default vlan 10
  5. 7. \[SW1\]interface eth0/0/2
  6. 8. \[SW1-Ethernet0/0/2\]port link-type access
  7. 9. \[SW1-Ethernet0/0/2\]port default vlan 20
  8. 11. \[SW1\]interface g0/0/1
  9. 12. \[Huawei-GigabitEthernet0/0/1\]port link-type trunk
  10. 13. \[Huawei-GigabitEthernet0/0/1\]port trunk allow-pass vlan 10 20

步骤二:配置路由器

  1. 1. \[R1\]interface g0/0/1.1
  2. 2. \[R1-GigabitEthernet0/0/1.1\]dot1q termination vid 10
  3. 3. \[R1-GigabitEthernet0/0/1.1\]ip address 10.10.0.1 24
  4. 4. \[R1-GigabitEthernet0/0/1.1\]arp broadcast enable
  5. 6. \[R1\]interface g0/0/1.2
  6. 7. \[R1-GigabitEthernet0/0/1.2\]dot1q termination vid 20
  7. 8. \[R1-GigabitEthernet0/0/1.2\]ip address 10.20.0.1 24
  8. 9. \[R1-GigabitEthernet0/0/1.2\]arp broadcast enable

步骤三:测试

使用 ping 命令测试,如图 - 4 所示。

CASE - 图4

图 - 4

5 路由网综合案例

5.1 问题

1)如图配置不同 PC 的 IP 地址和网关

2)每个 VLAN 的 IP 地址为 192.168.XX.0/24(XX 为 vlan 号)

3)每个 VLAN 内的主机的网关 IP 地址为 192.168.XX.254,XX 为 vlan 号

4)确保不同网段的 PC 是可以互通的

5.2 方案

使用 eNSP 搭建实验环境,如图 - 6 所示。

CASE - 图5

图 - 6

5.3 步骤

实现此案例需要按照如下步骤进行。

1)配置 PC 的 IP 地址和网关

2) 配置 SW1/5/6 的 vlan 为 10/20/30,交换机之间的链路为 Trunk,与 PC 间为 Access

3)配置 SW2/3/7 的 vlan 为 40/50,交换机之间的链路为 Trunk,与 PC 间为 Access

4) 配置 SW4/8/9 的 vlan 为 60/70/80,交换机之间的链路为 Trunk,与 PC 间为 Access

5)配置 R1/R2/R3 的接口 IP 地址

6)配置每个 VLAN 的网关接口 IP 地址

  1. 1. SW1vlan10/20/30的网关设备:
  2. 2. interface vlanif 10
  3. 3. ip address 192.168.10.254 24
  4. 4. quit
  5. 5. interface vlanif 20
  6. 6. ip address 192.168.20.254 24
  7. 7. quit
  8. 8. interface vlanif 30
  9. 9. ip address 192.168.30.254 24
  10. 10. quit
  11. 12. SW2 vlan 40 的网关:
  12. 13. interface vlanif 40
  13. 14. ip address 192.168.40.254 24
  14. 15. quit
  15. 17. SW3 vlan 50 的网关:
  16. 18. interface vlanif 50
  17. 19. ip address 192.168.50.254 24
  18. 20. quit
  19. 22. R3 gi0/0/0为 vlan60/70/80 的网关:
  20. 23. interface gi0/0/0.60
  21. 24. dot1q termination vid 60
  22. 25. arp broadcast enable
  23. 26. ip address 1921.68.60.254 24
  24. 27. quit
  25. 29. interface gi0/0/0.70
  26. 30. dot1q termination vid 70
  27. 31. arp broadcast enable
  28. 32. ip address 1921.68.70.254 24
  29. 33. quit
  30. 35. interface gi0/0/0.80
  31. 36. dot1q termination vid 80
  32. 37. arp broadcast enable
  33. 38. ip address 1921.68.80.254 24
  34. 39. quit

7)在 SW1 与 R1 之间添加 vlan 100,实现两者互通

  1. 1. SW1
  2. 2. vlan 100
  3. 3. quit
  4. 5. interface gi0/0/1
  5. 6. port link-type access
  6. 7. port default vlan 100
  7. 8. quit
  8. 10. interface vlanif 100
  9. 11. ip address 192.168.100.100 24
  10. 12. quit
  11. 14. ip route-static 0.0.0.0 0 192.168.100.1
  12. 16. R1:
  13. 17. interface gi0/0/0
  14. 18. ip address 192.168.100.1 24
  15. 19. quit
  16. 21. ip route-static 192.168.10.0 24 192.168.100.100
  17. 22. ip route-static 192.168.20.0 24 192.168.100.100
  18. 23. ip route-static 192.168.30.0 24 192.168.100.100
  19. 24. ip route-static 192.168.40.0 24 192.168.12.2
  20. 25. ip route-static 192.168.50.0 24 192.168.12.2
  21. 26. ip route-static 192.168.60.0 24 192.168.12.2
  22. 27. ip route-static 192.168.70.0 24 192.168.12.2
  23. 28. ip route-static 192.168.80.0 24 192.168.12.2

8)在 SW2 与 R2 之间添加 vlan 400,实现两者互通

  1. 1. SW2:
  2. 2. vlan 400
  3. 3. quit
  4. 5. interface gi0/0/1
  5. 6. port link-type access
  6. 7. port default vlan 400
  7. 8. quit
  8. 10. interface vlanif 400
  9. 11. ip address 192.168.200.3 24
  10. 12. quit
  11. 14. ip route-static 0.0.0.0 0 192.168.200.2
  12. 16. R2
  13. 17. interface gi0/0/0
  14. 18. ip address 192.168.200.2 24
  15. 19. quit
  16. 21. ip route-static 192.168.40.0 24 192.168.200.3

9)在 SW3 与 R2 之间添加 vlan 500,实现两者互通

  1. 1. SW3:
  2. 2. vlan 500
  3. 3. quit
  4. 5. interface gi0/0/1
  5. 6. port link-type access
  6. 7. port default vlan 500
  7. 8. quit
  8. 10. interface vlanif 500
  9. 11. ip address 192.168.255.3 24
  10. 12. quit
  11. 14. ip route-static 0.0.0.0 0 192.168.255.2
  12. 16. R2
  13. 17. interface gi4/0/0
  14. 18. ip address 192.168.255.2 24
  15. 19. quit
  16. 21. ip route-static 192.168.50.0 24 192.168.255.3
  17. 22. ip route-static 192.168.10.0 24 192.168.12.1
  18. 23. ip route-static 192.168.20.0 24 192.168.12.1
  19. 24. ip route-static 192.168.30.0 24 192.168.12.1
  20. 25. ip route-static 192.168.60.0 24 192.168.23.3
  21. 26. ip route-static 192.168.70.0 24 192.168.23.3
  22. 27. ip route-static 192.168.80.0 24 192.168.23.3

10)在 R3 上配置路由条目信息,实现与其他 PC 所在的网段的互通

  1. 1. ip route-static 192.168.10.0 24 192.168.23.2
  2. 2. ip route-static 192.168.20.0 24 192.168.23.2
  3. 3. ip route-static 192.168.30.0 24 192.168.23.2
  4. 4. ip route-static 192.168.40.0 24 192.168.23.2
  5. 5. ip route-static 192.168.50.0 24 192.168.23.2
  6. 6. ip route-static 192.168.60.0 24 192.168.23.2

11)测试不同网段的 PC 之间的连通性
https://tts.tmooc.cn/ttsPage/NTD/NTDTN202109/TCNA/DAY03/CASE/01/index.html