ROS软路由论坛 ROSABC.com 网络方案网络工程交流

 找回密码
 会员注册

QQ登录

只需一步,快速开始

第五篇:配置OSPF路由的五个步骤和全部配置命令行

2014-2-3 00:49| 发布者: admin| 查看: 861| 评论: 0

摘要: 对于ospf路由协议的配置,下面的教程共分了五个步骤,包括基本IP通讯、宣告OSPF路由到对应区域、查看路由表、打通虚电路、再次查看路由表。全部的配置命令行都列了出来,供网管参考和学习。 第一步:基本IP通讯! ...

对于ospf路由协议的配置,下面的教程共分了五个步骤,包括基本IP通讯、宣告OSPF路由到对应区域、查看路由表、打通虚电路、再次查看路由表。全部的配置命令行都列了出来,供网管参考和学习。

第一步:基本IP通讯!

R1>en
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int s0/0
R1(config-if)#no sh     
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#exit
R1(config)#int s0/1
R1(config-if)#no sh
R1(config-if)#ip add 192.168.13.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#exit
R1(config)#
-----------------------

R2>en
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int s0/0
R2(config-if)#no sh
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#exit
R2(config)#int s0/1
R2(config-if)#no sh
R2(config-if)#ip add 192.168.24.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#exit
R2(config)#
------------------------

R3>en
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int s0/1
R3(config-if)#no sh
R3(config-if)#ip add 192.168.13.3 255.255.255.0
R3(config-if)#exit
R3(config)#int s0/0
R3(config-if)#no sh
R3(config-if)#ip add 192.168.35.3 255.255.255.0
R3(config-if)#clock rate 64000
R3(config-if)#exit
R3(config)#
-----------------------

R4>en
R4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int s0/1
R4(config-if)#no sh
R4(config-if)#ip add 192.168.24.4 255.255.255.0
R4(config-if)#exit
R4(config)#
-----------------------

R5>en
R5#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R5(config)#int s0/0
R5(config-if)#no sh
R5(config-if)#ip add 192.168.35.5 255.255.255.0
R5(config-if)#exit
R5(config)#
---------------------

第二步:宣告OSPF路由到对应区域!
R1(config)#router ospf 1     ----这里的“1”不像eigrp里面的一样,这里的是进程号,不需要全部一致!
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 192.168.12.1 0.0.0.0 area 0          -------区域0(骨干区域)
R1(config-router)#net 192.168.13.1 0.0.0.0 area 13        --------区域13(常规区域)
R1(config-router)#end
R1#

在这里我解释下:除区域0以外全部都是常规区域!

R2(config)#router ospf 1                                           R2(config-router)#router-id 2.2.2.2                                       
R2(config-router)#net 192.168.12.2 0.0.0.0 area 0
R2(config-router)#net 192.168.24.2 0.0.0.0 area 24
R2(config-router)#end
R2#
-----------------------

R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#net 192.168.13.3 0.0.0.0 area 13
R3(config-router)#net 192.168.35.3 0.0.0.0 area 35
R3(config-router)#end
R3#
------------------

R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#net 192.168.24.4 0.0.0.0 area 24
R4(config-router)#end
R4#
--------------------------------------------------------------------------------------------------R5(config)#router ospf 1
R5(config-router)#router-id 5.5.5.5
R5(config-router)#net 192.168.35.5 0.0.0.0 area 35
R5(config-router)#end
R5#


第三步:查看路由表!
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C    192.168.12.0/24 is directly connected, Serial0/0
C    192.168.13.0/24 is directly connected, Serial0/1
O IA 192.168.24.0/24 [110/128] via 192.168.12.2, 00:05:25, Serial0/---O IA代表从其他区域学到的路由
R1#
---------------

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C    192.168.12.0/24 is directly connected, Serial0/0
O IA 192.168.13.0/24 [110/128] via 192.168.12.1, 00:04:45, Serial0/0
C    192.168.24.0/24 is directly connected, Serial0/1
R2#
-------------------

R3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/128] via 192.168.13.1, 00:04:28, Serial0/1
C    192.168.13.0/24 is directly connected, Serial0/1
O IA 192.168.24.0/24 [110/192] via 192.168.13.1, 00:04:28, Serial0/1
C    192.168.35.0/24 is directly connected, Serial0/0
R3#
-------------------

R4#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/128] via 192.168.24.2, 00:05:03, Serial0/1
O IA 192.168.13.0/24 [110/192] via 192.168.24.2, 00:05:03, Serial0/1
C    192.168.24.0/24 is directly connected, Serial0/1
R4#
------------

R5#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C    192.168.35.0/24 is directly connected, Serial0/0
R5#

这里可以看出除R5外全部都学到了路由,R5未学到其他路由也未让别人学到它的路由!这是因为常规区域必须都直接连到骨干区域!在显示生活中当然有这种情况,解决办法就是在R1和R3之间打通一条虚电路!


第四步:打通虚电路!
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router ospf 1
R1(config-router)#area 13 virtual-link 3.3.3.3
R1(config-router)#end
R1# http://www.luyouqiwang.com/15534/ 
------------------
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router ospf 1
R3(config-router)#area 13 virtual-link 1.1.1.1
R3(config-router)#end
R3#


第五步:再次查看路由表!
R1#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C    192.168.12.0/24 is directly connected, Serial0/0
C    192.168.13.0/24 is directly connected, Serial0/1
O IA 192.168.24.0/24 [110/128] via 192.168.12.2, 00:01:41, Serial0/0


O IA 192.168.35.0/24 [110/128] via 192.168.13.3, 00:01:41, Serial0/1
R1#
-------------------

R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C    192.168.12.0/24 is directly connected, Serial0/0
O IA 192.168.13.0/24 [110/128] via 192.168.12.1, 00:01:41, Serial0/0
C    192.168.24.0/24 is directly connected, Serial0/1
O IA 192.168.35.0/24 [110/192] via 192.168.12.1, 00:01:41, Serial0/0
R2#
-----------------------

-R3#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O    192.168.12.0/24 [110/128] via 192.168.13.1, 00:01:49, Serial0/1
C    192.168.13.0/24 is directly connected, Serial0/1
O IA 192.168.24.0/24 [110/192] via 192.168.13.1, 00:01:49, Serial0/1
C    192.168.35.0/24 is directly connected, Serial0/0
R3#
-------------------

R4#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/128] via 192.168.24.2, 00:05:04, Serial0/1
O IA 192.168.13.0/24 [110/192] via 192.168.24.2, 00:05:04, Serial0/1
C    192.168.24.0/24 is directly connected, Serial0/1
O IA 192.168.35.0/24 [110/256] via 192.168.24.2, 00:01:53, Serial0/1


R4#
--------------------

R5#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O IA 192.168.12.0/24 [110/192] via 192.168.35.3, 00:01:58, Serial0/0
O IA 192.168.13.0/24 [110/128] via 192.168.35.3, 00:02:14, Serial0/0
O IA 192.168.24.0/24 [110/256] via 192.168.35.3, 00:01:58, Serial0/0
C    192.168.35.0/24 is directly connected, Serial0/0
R5#
     
这个时候所有路由全部学习到了!

第六步:ping测试!

R4#ping 192.168.12.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/25/44 ms
R4#ping 192.168.13.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.13.1, timeout is 2 seconds:
!!!!! http://www.luyouqiwang.com/15534/ 
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/41/64 ms
R4#ping 192.168.35.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.35.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/54/80 ms
R4#ping 192.168.35.5
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.35.5, timeout is 2 seconds:


!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/51/88 ms
R4#

 到这里又得给各位说再见了,算是告一段落了!这个ospf配置的教程写的不好,谢谢大家的阅览!
 

不良信息举报Q:2000617

软路由

不良信息举报Q:2000617|Archiver|ROS软路由论坛 ROSABC.com 网络方案网络工程交流

GMT+8, 2024-5-14 20:28 , Processed in 0.202638 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部