当前位置:   article > 正文

思科CiscoRIP&OSPF重分布综合实验

思科CiscoRIP&OSPF重分布综合实验

实验涉及知识点:

vlan规划,单臂路由子接口,rip与ospf使用与重分布,默认路由注入、NAT

设备需求:

路由器*7

三层交换机*1

二层交换机*2

PC*4

实验拓扑图:

实验结果:

所有计算机可以与27.27.27.2通信,pc0可以与pc3通信

实验任务:

路由器配置:

R1、R2之间运行RIPv2协议

R3g0/1接口发布至ripv2,g0/0发布至ospf的区域0

R4、R5、R6之间运行ospf协议,其中R4,R5发布至区域0,R5的g0/0接口与R6发布至区域1

R3配置nat协议,所有内网ip转换为网段27.27.27.0/24

各路由器和三层交换机等设备配置回环地址,ip地址,vlan划分详情见下

路由器配置表

设备名称接口       IP地址
R1g0/111.11.11.2/24
R1g0/012.12.12.1/24
R2g0/012.12.12.2/24
R2g0/123.23.23.1/24
R3g0/123.23.23.2/24
R3g0/034.34.34.1/24
R3g0/227.27.27.1/24
R4g0/0       34.34.34.2/24
R4g0/145.45.45.1/24
R5g0/145.45.45.2/24
R5g0/056.56.56.1/24
R6g0/056.56.56.2/24
R6g0/1.10172.16.10.1/24
R6g0/1.20172.16.20.1/24
R7g0/227.27.27.2/24

路由器回环地址配置

设备名称       路由器回环地址
R11.1.1.1/32
R22.2.2.2/32
............
R77.7.7.7/32
S1101.1.1.1/32

交换机配置

设备名称配置要求
S0

f0/10-vlan10

f0/20-vlan20

S1

vlan10--192.168.10.1/24

vlan20--192.168.20.1/24

S2

f0/2-vlan10

f0/3-vlan20

路由器配置部分:

路由器地址配置 

  1. Router>enable
  2. Router#configure terminal
  3. Router(config)#hostname R1
  4. R1(config)#interface g0/1
  5. R1(config-if)#no shutdown
  6. R1(config-if)#ip address 11.11.11.2 255.255.255.0
  7. R1(config-if)#interface g0/0
  8. R1(config-if)#no shutdown
  9. R1(config-if)#ip address 12.12.12.1 255.255.255.0
  10. ------------------
  11. Router>
  12. Router>enable
  13. Router#conf t
  14. Router(config)#hostname R2
  15. R2(config)#interface g0/0
  16. R2(config-if)#no shutdown
  17. R2(config-if)#ip address 12.12.12.2 255.255.255.0
  18. R2(config-if)#interface g0/1
  19. R2(config-if)#no shutdown
  20. R2(config-if)#ip address 23.23.23.1 255.255.255.0
  21. ------------------------
  22. //剩余的ip地址部分以此类推
  23. Router>enable
  24. Router#configure terminal
  25. Router(config)#hostname R6
  26. R6(config)#interface g0/0
  27. R6(config-if)#no shutdown
  28. R6(config-if)#ip address 56.56.56.2 255.255.255.0
  29. R6(config-if)#interface g0/1.10
  30. R6(config-subif)#encapsulation dot1q 10#封装子接口vlanid为10
  31. R6(config-subif)#ip address 172.16.10.1 255.255.255.0
  32. R6(config-subif)#no shutdown
  33. R6(config-subif)#int g0/1.20
  34. R6(config-subif)#no shutdown
  35. R6(config-subif)#encapsulation dot1q 20#封装子接口vlanid为20
  36. R6(config-subif)#ip add 172.16.20.1 255.255.255.0
  37. R6(config-subif)#int g0/1
  38. R6(config-if)#no shutdown

路由器回环地址配置

  1. R1(config)#interface loopback 0
  2. R1(config-if)#ip address 1.1.1.1 255.255.255.255
  3. #回环地址的网络掩码为32
  4. .....
  5. R7(config)#interface loopback 0
  6. R7(config-if)#ip address 7.7.7.7 255.255.255.255

路由器协议配置

  1. #RIPv2配置部分
  2. R1(config)#router rip
  3. R1(config-router)#version 2
  4. R1(config-router)#no auto
  5. R1(config-router)#no auto-summary
  6. R1(config-router)#network 11.11.11.0
  7. R1(config-router)#network 12.12.12.0
  8. #---------------
  9. R2(config)#router rip
  10. R2(config-router)#version 2
  11. R2(config-router)#no auto-summary
  12. R2(config-router)#network 12.12.12.0
  13. R2(config-router)#network 23.23.23.0
  14. #-------------------
  15. R3(config)#router rip
  16. R3(config-router)#version 2
  17. R3(config-router)#no auto-summary
  18. R3(config-router)#network 23.23.23.0
  19. #---------------------
  20. #------------------
  21. #OSPF配置部分
  22. R3(config)#router ospf 1
  23. R3(config-router)#network 34.34.34.0 0.0.0.255 area 0
  24. #------------------
  25. R4(config)#router ospf 1
  26. R4(config-router)#network 34.34.34.0 0.0.0.255 area 0
  27. R4(config-router)#network 45.45.45.0 0.0.0.255 area 0
  28. #-------------------
  29. R5(config)#router ospf 1
  30. R5(config-router)#network 45.45.45.0 0.0.0.255 area 0
  31. R5(config-router)#network 56.56.56.0 0.0.0.255 area 1#注意发布区域
  32. #--------------
  33. R6(config)#router ospf 1
  34. R6(config-router)#network 56.56.56.0 0.0.0.255 area 1
  35. R6(config-router)#network 172.16.0.0 0.0.255.255 area 1

路由器协议配置检查

  1. #此时R1路由表
  2. R1#show ip route
  3. Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
  4. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  5. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  6. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  7. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  8. * - candidate default, U - per-user static route, o - ODR
  9. P - periodic downloaded static route
  10. Gateway of last resort is not set
  11. 1.0.0.0/32 is subnetted, 1 subnets
  12. C 1.1.1.1/32 is directly connected, Loopback0
  13. 11.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
  14. C 11.11.11.0/24 is directly connected, GigabitEthernet0/1
  15. L 11.11.11.2/32 is directly connected, GigabitEthernet0/1
  16. 12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
  17. C 12.12.12.0/24 is directly connected, GigabitEthernet0/0
  18. L 12.12.12.1/32 is directly connected, GigabitEthernet0/0
  19. 23.0.0.0/24 is subnetted, 1 subnets
  20. R 23.23.23.0/24 [120/1] via 12.12.12.2, 00:00:10, GigabitEthernet0/0
  1. #此时R6路由表
  2. R6#
  3. %SYS-5-CONFIG_I: Configured from console by console
  4. show ip route
  5. Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
  6. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
  7. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  8. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
  9. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
  10. * - candidate default, U - per-user static route, o - ODR
  11. P - periodic downloaded static route
  12. Gateway of last resort is not set
  13. 6.0.0.0/32 is subnetted, 1 subnets
  14. C 6.6.6.6/32 is directly connected, Loopback0
  15. 34.0.0.0/24 is subnetted, 1 subnets
  16. O IA 34.34.34.0/24 [110/3] via 56.56.56.1, 00:03:09, GigabitEthernet0/0
  17. #另一区域的路由
  18. 45.0.0.0/24 is subnetted, 1 subnets
  19. O IA 45.45.45.0/24 [110/2] via 56.56.56.1, 00:03:09, GigabitEthernet0/0
  20. 56.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
  21. C 56.56.56.0/24 is directly connected, GigabitEthernet0/0
  22. L 56.56.56.2/32 is directly connected, GigabitEthernet0/0
  23. 172.16.0.0/16 is variably subnetted, 4 subnets, 2 masks
  24. C 172.16.10.0/24 is directly connected, GigabitEthernet0/1.10
  25. L 172.16.10.1/32 is directly connected, GigabitEthernet0/1.10
  26. C 172.16.20.0/24 is directly connected, GigabitEthernet0/1.20
  27. L 172.16.20.1/32 is directly connected, GigabitEthernet0/1.20

路由重分布配置

  1. #RIPv2重分布
  2. R3(config)#router rip
  3. R3(config-router)#redistribute ospf 1 metric 2
  4. #将R3上ospf 1 的路由条目重分布至rip中

配置完成后在R1执行“show ip route"将可以看到以下路由条目

  1. 34.0.0.0/24 is subnetted, 1 subnets
  2. R 34.34.34.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
  3. 45.0.0.0/24 is subnetted, 1 subnets
  4. R 45.45.45.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
  5. 56.0.0.0/24 is subnetted, 1 subnets
  6. R 56.56.56.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
  7. 172.16.0.0/24 is subnetted, 2 subnets
  8. R 172.16.10.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0
  9. R 172.16.20.0/24 [120/3] via 12.12.12.2, 00:00:08, GigabitEthernet0/0

rip重分布配置完成。

  1. #OSPF重分布
  2. R3(config)#router ospf 1
  3. R3(config-router)#redistribute rip subnets
  4. R3(config-router)#redistribute rip metric 2

配置完成后在R6执行”show ip route"可以看到以下路由条目

  1. O E2 11.11.11.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
  2. 12.0.0.0/24 is subnetted, 1 subnets
  3. O E2 12.12.12.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
  4. 23.0.0.0/24 is subnetted, 1 subnets
  5. O E2 23.23.23.0/24 [110/2] via 56.56.56.1, 00:00:10, GigabitEthernet0/0
  6. 34.0.0.0/24 is subnetted, 1 subnets
  7. O IA 34.34.34.0/24 [110/3] via 56.56.56.1, 00:07:57, GigabitEthernet0/0
  8. 45.0.0.0/24 is subnetted, 1 subnets
  9. O IA 45.45.45.0/24 [110/2] via 56.56.56.1, 00:07:57, GigabitEthernet0/0
  10. #O E2表示重分布的路由
  11. #O IA表示非本区域的路由

OSPF重分布配置完成

路由器默认路由注入

RIP默认路由注入

  1. R3(config)#ip route 0.0.0.0 0.0.0.0 27.27.27.2
  2. #先写一个R3的默认路由
  3. R3(config)#router rip
  4. R3(config-router)#default-information originate
  5. #向使用RIP协议的路由器注入默认路由

配置完成后,可以在R1路由表发现以下条目

  1. R* 0.0.0.0/0 [120/2] via 12.12.12.2, 00:00:19, GigabitEthernet0/0
  2. #默认路由的概念是当路由器不知道转发给谁时就会按照默认路由转发给下一跳

OSPF默认路由注入

  1. R3(config)#router ospf 1
  2. R3(config-router)#default-information originate

配置完成后可以在R6路由表发现以下条目

O*E2 0.0.0.0/0 [110/1] via 56.56.56.1, 00:00:07, GigabitEthernet0/0

路由器NAT配置

  1. R3(config)#access-list 10 permit any
  2. #所有主机都将被转换
  3. R3(config)#ip nat pool pool_all 27.27.27.10 27.27.27.254 netmask 255.255.255.0
  4. #创建转换池,pool_all是转换池的名称,转换范围是10-254(动态nat)
  5. #---------------#
  6. R3(config)#interface g0/2
  7. R3(config-if)#ip nat outside
  8. R3(config-if)#interface g0/1
  9. R3(config-if)#ip nat inside
  10. R3(config-if)#interface g0/0
  11. R3(config-if)#ip nat inside
  12. #g0/2外网接口,g0/0-1内网接口
  13. #---------------#
  14. R3(config-if)#exit
  15. R3(config)#ip nat inside source list 10 pool pool_all
  16. #将acl表与转换池绑定

路由器部分配置完毕

交换机配置部分

  1. Switch>enable
  2. Switch#configure terminal
  3. Switch(config)#hostname S0
  4. S0(config)#vlan 10
  5. S0(config-vlan)#vlan 20
  6. S0(config-vlan)#exit
  7. S0(config)#interface f0/2
  8. S0(config-if)#switchport mode trunk
  9. S0(config-if)#exit
  10. S0(config)#interface f0/10
  11. S0(config-if)#switchport access vlan 10
  12. S0(config-if)#interface f0/20
  13. S0(config-if)#switchport access vlan 20
  1. Switch>enable
  2. Switch#configure terminal
  3. Switch(config)#hostname S1
  4. S1(config)#vlan 10
  5. S1(config-vlan)#vlan 20
  6. S1(config-vlan)#exit
  7. S1(config)#interface loopback 0
  8. S1(config-if)#ip address 101.1.1.1 255.255.255.255#配置回环地址
  9. S1(config-if)#exit
  10. S1(config)#interface vlan 10
  11. S1(config-if)#no shutdown
  12. S1(config-if)#ip address 192.168.10.1 255.255.255.0
  13. S1(config-if)#interface vlan 20
  14. S1(config-if)#no shutdown
  15. S1(config-if)#ip address 192.168.20.1 255.255.255.0
  16. S1(config-if)#exit
  17. S1(config)#interface range f0/2
  18. S1(config-if-range)#switchport trunk encapsulation dot1q#封装协议
  19. S1(config-if-range)#switchport mode trunk
  20. S1(config)#ip routing#打开三层功能
  21. S1(config)#int f0/1
  22. S1(config-if)#no switchport #成为三层路由接口
  23. S1(config-if)#ip add 11.11.11.1 255.255.255.0
  24. S1(config-if-range)#exit
  25. S1(config)#router rip
  26. S1(config-router)#version 2
  27. S1(config-router)#no auto-summary
  28. S1(config-router)#network 11.11.11.0
  29. S1(config-router)#network 192.168.10.0
  30. S1(config-router)#network 192.168.20.0
  1. Switch>enable
  2. Switch#configure terminal
  3. Switch(config)#hostname S2
  4. S2(config)#interface f0/1
  5. S2(config-if)#switchport mode trunk
  6. S2(config-if)#vlan 10
  7. S2(config-vlan)#vlan 20
  8. S2(config-vlan)#interface f0/2
  9. S2(config-if)#switchport access vlan 10
  10. S2(config-if)#int f0/3
  11. S2(config-if)#switchport acces vlan 20

交换机配置完成

测试部分

测试之前,请确保pc机按照以下配置完成并检查接口

设备名称ip地址网关
pc0192.168.10.2/24192.168.10.1
pc1192.168.20.2/24192.168.20.1
pc2172.16.10.2/24172.16.10.1
pc3172.16.20.2/24172.16.20.1

pc0tracert-》pc3

成功

NAT测试

  1. R3#show ip nat translations
  2. Pro Inside global Inside local Outside local Outside global
  3. icmp 27.27.27.10:29 192.168.10.2:29 27.27.27.2:29 27.27.27.2:29
  4. icmp 27.27.27.10:30 192.168.10.2:30 27.27.27.2:30 27.27.27.2:30
  5. icmp 27.27.27.10:31 192.168.10.2:31 27.27.27.2:31 27.27.27.2:31
  6. icmp 27.27.27.10:32 192.168.10.2:32 27.27.27.2:32 27.27.27.2:32
  7. udp 27.27.27.11:1025 27.27.27.1:1025 255.255.255.255:53 255.255.255.255:53

NAT配置成功

目的达成,实验完毕

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/585323
推荐阅读
相关标签
  

闽ICP备14008679号