细初版OSPF实验.docx
- 文档编号:20133857
- 上传时间:2023-04-25
- 格式:DOCX
- 页数:76
- 大小:107.41KB
细初版OSPF实验.docx
《细初版OSPF实验.docx》由会员分享,可在线阅读,更多相关《细初版OSPF实验.docx(76页珍藏版)》请在冰豆网上搜索。
细初版OSPF实验
1、基本配置实验1
2、验证性实验6
2.1、邻居状态验证6
2.1.1、OSPF邻居状态(init)6
2.1.2、OSPF邻居状态(two-way)8
2.1.3、OSPF邻居状态(Exstart)9
2.1.4、OSPF邻居状态(loaning)11
2.2、DR与BDR选举问题11
3、OSPF的几种网络类型13
3.1、NBMA非广播上的OSPF配置14
3.2、NBMA广播上的OSPF配置17
3.3、NBMA点到多点的OSPF配置19
3.4、NBMA点到点子接口配置19
4、OSPFLSDB和路由选择表21
5、OSPF的路由汇总28
6、特殊的OSPF区域类型37
7、OSPF的各种LSA45
8、OSPF虚链路46
9、配置OSPF身份认证49
10、OSPF的路由策略配置52
11、OSPF小综合52
1、基本配置实验
拓扑如下图所示:
图一
基本配置如下:
R1配置:
Router>
Router>en
Router#conft
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Router(config)#noipdomain-lookup
Router(config)#hostR1
R1(config)#intf0/0
R1(config-if)#ipaddress10.1.1.1255.255.255.0
R1(config-if)#nosh
R1(config-if)#exit
R1(config)#intloopback0
R1(config-if)#ipaddress1.1.1.1255.255.255.0
R1(config-if)#exit
R1(config)#routerospf1
R1(config-router)#network10.1.1.00.0.0.255a
R1(config-router)#network10.1.1.00.0.0.255area0
R1(config-router)#network1.1.1.00.0.0.255area0
R1(config-router)#exit
R2配置:
Router>
Router>en
Router#conft
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Router(config)#noipdomain-lookup
Router(config)#hostR2
R2(config)#intf0/0
R2(config-if)#ipaddress10.1.1.2255.255.255.0
R2(config-if)#nosh
R2(config-if)#exit
R2(config)#ints1/0
R2(config-if)#ipaddress10.1.2.1255.255.255.0
R2(config-if)#nosh
R2(config-if)#exit
R2(config)#intlo0
R2(config-if)#ipaddress2.2.2.2255.255.255.0
R2(config-if)#exit
R2(config)#routerospf1
R2(config-router)#network10.1.1.00.0.0.255a0
R2(config-router)#network10.1.2.00.0.0.255a0
R2(config-router)#network2.2.2.00.0.0.255a0
R2(config-router)#exit
R3配置:
Router>
Router>en
Router#conft
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Router(config)#noipdomain-lo
Router(config)#hostR3
R3(config)#ints1/0
R3(config-if)#ipaddress10.1.2.2255.255.255.0
R3(config-if)#nosh
R3(config-if)#exit
R3(config)#intlo0
R3(config-if)#ipaddress3.3.3.3255.255.255.0
R3(config-if)#exit
R3(config)#routerospf1
R3(config-router)#network10.1.2.00.0.0.255a0
R3(config-router)#network3.3.3.00.0.0.255a0
R3(config-router)#exit
通过showipprotocol、showiprouterospf、showipospfinterface、showipospf等命令查看配置信息。
R1#showipprotocols
RoutingProtocolis"ospf1"
Outgoingupdatefilterlistforallinterfacesisnotset
Incomingupdatefilterlistforallinterfacesisnotset
RouterID1.1.1.1
Numberofareasinthisrouteris1.1normal0stub0nssa
Maximumpath:
4
RoutingforNetworks:
1.1.1.00.0.0.255area0
10.1.1.00.0.0.255area0
Referencebandwidthunitis100mbps
RoutingInformationSources:
GatewayDistanceLastUpdate
3.3.3.311000:
02:
36
2.2.2.211000:
02:
36
Distance:
(defaultis110)
通过这个命令可以看到路由器配置的路由信息,这里可以看到配置的是ospf,并且进程ID是1。
而ospf的RID是1.1.1.1。
通过ospf通过的网络分别是1.1.1.0/24和10.1.1.0/24。
R1#showiproute
Codes:
C-connected,S-static,R-RIP,M-mobile,B-BGP
D-EIGRP,EX-EIGRPexternal,O-OSPF,IA-OSPFinterarea
N1-OSPFNSSAexternaltype1,N2-OSPFNSSAexternaltype2
E1-OSPFexternaltype1,E2-OSPFexternaltype2
i-IS-IS,su-IS-ISsummary,L1-IS-ISlevel-1,L2-IS-ISlevel-2
ia-IS-ISinterarea,*-candidatedefault,U-per-userstaticroute
o-ODR,P-periodicdownloadedstaticroute
Gatewayoflastresortisnotset
1.0.0.0/24issubnetted,1subnets
C1.1.1.0isdirectlyconnected,Loopback0
2.0.0.0/32issubnetted,1subnets
O2.2.2.2[110/2]via10.1.1.2,00:
05:
19,FastEthernet0/0
3.0.0.0/32issubnetted,1subnets
O3.3.3.3[110/66]via10.1.1.2,00:
05:
19,FastEthernet0/0
10.0.0.0/24issubnetted,2subnets
O10.1.2.0[110/65]via10.1.1.2,00:
05:
19,FastEthernet0/0
C10.1.1.0isdirectlyconnected,FastEthernet0/0
在R1上查看路由表,可以发现有三条的通过OSPF学到的路由,它们的AD都是110,metric分别是2、66、65。
主要因为2.2.2.2和3.3.3.3是stub路由,所以metric为1,以太网链路的metric是1,而专线的metric是64。
R1#showipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
2.2.2.21FULL/BDR00:
00:
3710.1.1.2FastEthernet0/0
R2#showipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
3.3.3.30FULL/-00:
00:
3210.1.2.2Serial1/0
1.1.1.11FULL/DR00:
00:
3810.1.1.1FastEthernet0/0
R3#showipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
2.2.2.20FULL/-00:
00:
3410.1.2.1Serial1/0
分别在R1、R2、R3使用showipospfneighbor这条命令,其中R1和R3有一个邻居,R2有两个邻居。
R1和R2因为是以太网链路,所以要选举DR和BDR,一般来说RID大的为DR,但由于R1比R2先启用OSPF的协议,所以成为了DR。
而R3和R2是点对点链路,不需要选举DR和BDR。
R1#showipospf
RoutingProcess"ospf1"withID1.1.1.1
Starttime:
00:
07:
36.520,Timeelapsed:
00:
19:
06.080
SupportsonlysingleTOS(TOS0)routes
SupportsopaqueLSA
SupportsLink-localSignaling(LLS)
Supportsareatransitcapability
Routerisnotoriginatingrouter-LSAswithmaximummetric
InitialSPFscheduledelay5000msecs
MinimumholdtimebetweentwoconsecutiveSPFs10000msecs
MaximumwaittimebetweentwoconsecutiveSPFs10000msecs
Incremental-SPFdisabled
MinimumLSAinterval5secs
MinimumLSAarrival1000msecs
LSAgrouppacingtimer240secs
Interfacefloodpacingtimer33msecs
Retransmissionpacingtimer66msecs
NumberofexternalLSA0.ChecksumSum0x000000
NumberofopaqueASLSA0.ChecksumSum0x000000
NumberofDCbitlessexternalandopaqueASLSA0
NumberofDoNotAgeexternalandopaqueASLSA0
Numberofareasinthisrouteris1.1normal0stub0nssa
Numberofareastransitcapableis0
Externalfloodlistlength0
IETFNSFhelpersupportenabled
CiscoNSFhelpersupportenabled
AreaBACKBONE(0)
Numberofinterfacesinthisareais2(1loopback)
Areahasnoauthentication
SPFalgorithmlastexecuted00:
14:
14.748ago
SPFalgorithmexecuted6times
Arearangesare
NumberofLSA4.ChecksumSum0x02B6CC
NumberofopaquelinkLSA0.ChecksumSum0x000000
NumberofDCbitlessLSA0
NumberofindicationLSA0
NumberofDoNotAgeLSA0
Floodlistlength0
通过showipospf这个命令可以看到一些关于OSPF的信息。
R2#showipospfneighbordetail
Neighbor3.3.3.3,interfaceaddress10.1.2.2
Inthearea0viainterfaceSerial1/0
Neighborpriorityis0,StateisFULL,6statechanges
DRis0.0.0.0BDRis0.0.0.0
Optionsis0x52
LLSOptionsis0x1(LR)
Deadtimerduein00:
00:
31
Neighborisupfor00:
16:
51
Index2/2,retransmissionqueuelength0,numberofretransmission1
First0x0(0)/0x0(0)Next0x0(0)/0x0(0)
Lastretransmissionscanlengthis1,maximumis1
Lastretransmissionscantimeis0msec,maximumis0msec
Neighbor1.1.1.1,interfaceaddress10.1.1.1
Inthearea0viainterfaceFastEthernet0/0
Neighborpriorityis1,StateisFULL,6statechanges
DRis10.1.1.1BDRis10.1.1.2
Optionsis0x52
LLSOptionsis0x1(LR)
Deadtimerduein00:
00:
37
Neighborisupfor00:
18:
52
Index1/1,retransmissionqueuelength0,numberofretransmission0
First0x0(0)/0x0(0)Next0x0(0)/0x0(0)
Lastretransmissionscanlengthis0,maximumis0
Lastretransmissionscantimeis0msec,maximumis0msec
通过showipospfneighbordetail显示一个邻居列表,包括它们的OSPF路由器ID,OSPF优先级,邻接关系(如init、预启动、完全连接等)及失效定时器。
另外可以在路由模式下通过router-idA.B.C.D这个命令来设置RID,不过工程上一般上配置使用loopback接口的地址作为RID。
2、验证性实验
2.1、邻居状态验证
2.1.1、OSPF邻居状态(init)
拓扑如下图所示:
图二
OSPF的基本配置参考第1部分。
首先不使用acl对数据包进行控制。
两个路由器的配置如下
R1:
interfaceLoopback0
ipaddress1.1.1.1255.255.255.0
!
!
!
interfaceSerial1/0
ipaddress10.1.1.1255.255.255.0
serialrestart-delay0
!
!
!
!
routerospf1
log-adjacency-changes
network1.1.1.00.0.0.255area0
network10.1.1.00.0.0.255area0
!
R2:
!
!
interfaceLoopback0
ipaddress2.2.2.2255.255.255.0
!
!
interfaceSerial1/0
ipaddress10.1.1.2255.255.255.0
serialrestart-delay0
!
routerospf1
log-adjacency-changes
network2.2.2.00.0.0.255area0
network10.1.1.00.0.0.255area0
!
通过命令查看邻居情况
R1#shipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
2.2.2.20FULL/-00:
00:
3110.1.1.2Serial1/0
R2#shipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
1.1.1.10FULL/-00:
00:
3510.1.1.1Serial1/0
可以看到两个路由器已经形成了邻居。
这时通过ACL对通过路由器的数据包进行控制,配置如下:
R1#conft
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
R1(config)#access-list1permit2.2.2.2
R1(config)#ints1/0
R1(config-if)#ipaccess-group1in
R1(config-if)#exit
这时再通过命令来查看邻接信息
R1#shipospfneighbor
R1#
R2#shipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
1.1.1.10INIT/-00:
00:
3110.1.1.1Serial1/0
在R1里没有发现邻居信息。
而在R2上虽然可以看到R1但R1处于初始化的状态,这样是不能形成邻接关系的,也不能交换各自的路由信息。
这主要是因为R1上的ACL挡住了来自R2的Hello包,所以R1不能与R2形成邻居,而R2虽然收到R1的Hello,并发出了带R1的Hello包,但R1不收。
2.1.2、OSPF邻居状态(two-way)
实验拓扑如下图所示:
图三
OSPF的基本配置参考第1部分。
这个实验与2.1.1不同的是中间连接的链路变成了以太网。
也就是所在two-way状态之后必须要选举DR和BDR。
实验的基本配置:
R1:
!
!
interfaceLoopback0
ipaddress1.1.1.1255.255.255.0
!
interfaceFastEthernet0/0
ipaddress10.1.1.1255.255.255.0
ipospfpriority0
duplexauto
speedauto
!
!
routerospf1
log-adjacency-changes
network1.1.1.00.0.0.255area0
network10.1.1.00.0.0.255area0
!
R2:
interfaceLoopback0
ipaddress2.2.2.2255.255.255.0
!
interfaceFastEthernet0/0
ipaddress10.1.1.2255.255.255.0
ipospfpriority0
duplexauto
speedauto
!
!
!
routerospf1
log-adjacency-changes
network2.2.2.00.0.0.255area0
network10.1.1.00.0.0.255area0
!
可以看到,这里更改了ospf接口的优先级,把两个路由器相连的接口都改为0了。
然后再查看ospf的邻居表。
R1#shipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
2.2.2.202WAY/DROTHER00:
00:
3210.1.1.2FastEthernet0/0
R2#shipospfneighbor
NeighborIDPriStateDeadTimeAddressInterface
1.1.1.102WAY/DROTHER00:
00:
3110.1.1.1FastEthernet0/0
可以看到,他们之间能成为two-way状态,并且由于不存在选举为DR和BDR的条件,所以停留在了two-way状态,而且都为DROTHER。
2.1.3、OSPF邻居状态(Exstart)
首先在2.1.2的基础上把两个接口的优先级改为默认值。
然后在R1的接口上修改MTU。
配置如下:
R1:
!
!
interfaceL
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 初版 OSPF 实验