学会配置单区域的OSPF网络
一、实验目的
1、理解Route-id的意义
2、掌握配置单区域的OSPF网络的方法
3、理解OSPF hello-interval和dead-interval的意义
二、实验拓扑
三、实验步骤
1、基本的配置与OSPF配置
AR1:
Enter system view, return user view with Ctrl+Z.
[Huawei]info-center source DS channel 0 log state off trap state off
[Huawei]sysname AR1
[AR1]int e0/0/0
[AR1-Ethernet0/0/0]ip add 192.168.12.1 30
[AR1-Ethernet0/0/0]int e0/0/1
[AR1-Ethernet0/0/1]ip add 192.168.13.1 30
[AR1-Ethernet0/0/1]int loo0
[AR1-LoopBack0]ip add 1.1.1.1 32
[AR1-LoopBack0]q
[AR1]ospf 1 router-id 1.1.1.1//手动配置Router-id
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.3
[AR1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[AR1-ospf-1-area-0.0.0.0]q
[AR1-ospf-1]q
[AR1]
AR2:
Enter system view, return user view with Ctrl+Z.
[Huawei]info-center source DS channel 0 log state off trap state off
[Huawei]sysname AR2
[AR2]int e0/0/0
[AR2-Ethernet0/0/0]ip add 192.168.12.2 30
[AR2-Ethernet0/0/0]int e0/0/1
[AR2-Ethernet0/0/1]ip add 192.168.23.1 30
[AR2-Ethernet0/0/1]int loo0
[AR2-LoopBack0]ip add 2.2.2.2 32
[AR2-LoopBack0]q
[AR2]ospf 1 router-id 2.2.2.2//手动配置Router-id
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]network 192.168.12.0 0.0.0.3
[AR2-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.3
[AR2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[AR2-ospf-1-area-0.0.0.0]q
[AR2-ospf-1]q
[AR2]
AR3:
Enter system view, return user view with Ctrl+Z.
[Huawei]info-center source DS channel 0 log state off trap state off
[Huawei]sysname AR3
[AR3]int e0/0/1
[AR3-Ethernet0/0/1]ip add 192.168.23.2 30
[AR3-Ethernet0/0/0]int loo0
[AR3-LoopBack0]ip add 3.3.3.3 32
[AR3]ospf 1 router-id 3.3.3.3//手动配置Router-id
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 192.168.23.0 0.0.0.3
[AR3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[AR3-ospf-1-area-0.0.0.0]q
[AR3-ospf-1]q
[AR3]
说明:一台路由器如果要运行OSPF协议,必须存在Router ID。路由器的ID是一个32比特无符号整数,是一台路由器在自治系统中的唯一标识。
路由器的ID可以手工配置,如果没有通过命令指定ID号,系统会从当前接口的IP地址中自动选取一个作为路由器的ID号。其选择顺序是:优先从Loopback地址中选择最大的IP地址作为路由器的ID号,如果没有配置Loopback接口,则在接口地址中选取最大的IP地址作为路由器的ID号。只有重新配置系统的Router ID或OSPF的Router ID,并且重新启动OSPF进程后,才会进行Router ID的重新选取。(在用户视图下用“reset ospf process”来重启进程)
2、查看ospf路由表
[AR1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8Routes : 8
Destination/MaskProtoPreCostFlags NextHopInterface
1.1.1.1/32Direct00D127.0.0.1LoopBack0
2.2.2.2/32OSPF101D192.168.12.2Ethernet0/0/0
3.3.3.3/32OSPF102D192.168.12.2Ethernet0/0/0
127.0.0.0/8Direct00D127.0.0.1InLoopBack0
127.0.0.1/32Direct00D127.0.0.1InLoopBack0
192.168.12.0/30Direct00D192.168.12.1Ethernet0/0/0
192.168.12.1/32Direct00D127.0.0.1Ethernet0/0/0
192.168.23.0/30OSPF102D192.168.12.2Ethernet0/0/0
[AR2]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9Routes : 9
Destination/MaskProtoPreCostFlags NextHopInterface
1.1.1.1/32OSPF101D192.168.12.1Ethernet0/0/0
2.2.2.2/32Direct00D127.0.0.1LoopBack0
3.3.3.3/32OSPF101D192.168.23.2Ethernet0/0/1
127.0.0.0/8Direct00D127.0.0.1InLoopBack0
127.0.0.1/32Direct00D127.0.0.1InLoopBack0
192.168.12.0/30Direct00D192.168.12.2Ethernet0/0/0
192.168.12.2/32Direct00D127.0.0.1Ethernet0/0/0
192.168.23.0/30Direct00D192.168.23.1Ethernet0/0/1
192.168.23.1/32Direct00D127.0.0.1Ethernet0/0/1
[AR3]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8Routes : 8
Destination/MaskProtoPreCostFlags NextHopInterface
1.1.1.1/32OSPF102D192.168.23.1Ethernet0/0/1
2.2.2.2/32OSPF101D192.168.23.1Ethernet0/0/1
3.3.3.3/32Direct00D127.0.0.1LoopBack0
127.0.0.0/8Direct00D127.0.0.1InLoopBack0
127.0.0.1/32Direct00D127.0.0.1InLoopBack0
192.168.12.0/30OSPF102D192.168.23.1Ethernet0/0/1
192.168.23.0/30 Direct00D192.168.23.2Ethernet0/0/1
192.168.23.2/32Direct00D127.0.0.1Ethernet0/0/1
3、查看它们的邻居关系
OSPF Process 1 with Router ID 1.1.1.1
Neighbors
Area 0.0.0.0 interface 192.168.12.1(Ethernet0/0/0)'s neighbors//区域0 e0/0/0接口从邻居接口收到的ID是2.2.2.2
Router ID: 2.2.2.2Address: 192.168.12.2
State: FullMode:Nbr isMasterPriority: 1
DR: 192.168.12.2BDR: 192.168.12.1MTU: 0
Dead timer due in 40sec
Retrans timer interval: 5
Neighbor is up for 00:00:42
Authentication Sequence: [ 0 ]
OSPF Process 1 with Router ID 2.2.2.2
Neighbors
Area 0.0.0.0 interface 192.168.12.2(Ethernet0/0/0)'s neighbors//区域0 e0/0/0接口从邻居接口收到的ID是1.1.1.1
Router ID: 1.1.1.1Address: 192.168.12.1
State: FullMode:Nbr isSlavePriority: 1
DR: 192.168.12.2BDR: 192.168.12.1MTU: 0
Dead timer due in 34sec
Retrans timer interval: 5
Neighbor is up for 00:05:05
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.0 interface 192.168.23.1(Ethernet0/0/1)'s neighbors//区域0 e0/0/1接口从邻居接口收到的ID是3.3.3.3
Router ID: 3.3.3.3Address: 192.168.23.2
State: FullMode:Nbr isMasterPriority: 1
DR: 192.168.23.2BDR: 192.168.23.1MTU: 0
Dead timer due in 36sec
Retrans timer interval: 5
Neighbor is up for 00:06:01
Authentication Sequence: [ 0 ]
[AR3]dis ospf peer
OSPF Process 1 with Router ID 3.3.3.3
Neighbors
Area 0.0.0.0 interface 192.168.23.2(Ethernet0/0/1)'s neighbors
Router ID: 2.2.2.2Address: 192.168.23.1
State: FullMode:Nbr isSlavePriority: 1
DR: 192.168.23.2BDR: 192.168.23.1MTU: 0
Dead timer due in 30sec
Retrans timer interval: 5
Neighbor is up for 00:16:58
Authentication Sequence: [ 0 ]
备注:从上面它们的邻居可以看出各接口之间谁是DR与BDR。
DR和BDR不是人为指定的,而是由本网段中所有的路由器共同选举出来的。路由器接口的DR优先级决定了该接口在选举DR、BDR时所具有的资格。
选举中使用的“选票”就是Hello报文。每台路由器将自己选出的DR写入Hello报文中,发给网段上的其他路由器。当处于同一网段的两台路由器同时宣布自己是DR时,DR优先级高者胜出。如果优先级相等,则Router ID大者胜出。如果一台路由器的优先级为0,则它不会被选举为DR或BDR
4、查看OSPF hello-interval和dead-interval
OSPF Process 1 with Router ID 1.1.1.1
Interfaces
Interface: 192.168.12.1 (Ethernet0/0/0)
Cost: 1State: BDRType: BroadcastMTU: 1500
Priority: 1
Designated Router: 192.168.12.2
Backup Designated Router: 192.168.12.1
Timers: Hello 10 , Dead 40 , Poll120 , Retransmit 5 , Transmit Delay 1
[AR2]dis ospf interface e0/0/0
OSPF Process 1 with Router ID 2.2.2.2
Interfaces
Interface: 192.168.12.2 (Ethernet0/0/0)
Cost: 1State: DRType: BroadcastMTU: 1500
Priority: 1
Designated Router: 192.168.12.2
Backup Designated Router: 192.168.12.1
Timers: Hello 10 , Dead 40 , Poll120 , Retransmit 5 , Transmit Delay 1
[AR2]dis ospf interface e0/0/1
OSPF Process 1 with Router ID 2.2.2.2
Interfaces
Interface: 192.168.23.1 (Ethernet0/0/1)
Cost: 1State: BDRType: BroadcastMTU: 1500
Priority: 1
Designated Router: 192.168.23.2
Backup Designated Router: 192.168.23.1
Timers: Hello 10 , Dead 40 , Poll120 , Retransmit 5 , Transmit Delay 1
OSPF Process 1 with Router ID 3.3.3.3
Interfaces
Interface: 192.168.23.2 (Ethernet0/0/1)
Cost: 1State: DRType: BroadcastMTU: 1500
Priority: 1
Designated Router: 192.168.23.2
Backup Designated Router: 192.168.23.1
Timers: Hello 10 , Dead 40 , Poll120 , Retransmit 5 , Transmit Delay 1
说明:从上面的信息可以看出Hellointerval缺省间隔为10秒
(1)修改AR2上的e0/0/1接口的Hello时间间隔为20s,查看路由表
[AR2]int e0/0/1
[AR2-Ethernet0/0/1]ospf timer hello 20
[AR2-Ethernet0/0/1]dis ospf int e0/0/1
OSPF Process 1 with Router ID 2.2.2.2
Interfaces
Interface: 192.168.23.1 (Ethernet0/0/1)
Cost: 1State: BDRType: BroadcastMTU: 1500
Priority: 1
Designated Router: 192.168.23.2
Backup Designated Router: 192.168.23.1
Timers: Hello 20 , Dead 80 , Poll120 , Retransmit 5 , Transmit Delay 1
(2)重启AR2上与AR3相连的e0/0/1口,查看路由表
[AR2-Ethernet0/0/1]shutdown
[AR2-Ethernet0/0/1]undo shutdown
[AR2-Ethernet0/0/1]q
[AR2]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8Routes : 8
Destination/MaskProtoPreCostFlags NextHopInterface
1.1.1.1/32OSPF101D192.168.12.1Ethernet0/0/0
2.2.2.2/32Direct00D127.0.0.1LoopBack0
127.0.0.0/8Direct00D127.0.0.1InLoopBack0
127.0.0.1/32Direct00D127.0.0.1InLoopBack0
192.168.12.0/30Direct00D192.168.12.2Ethernet0/0/0
192.168.12.2/32Direct00D127.0.0.1Ethernet0/0/0
192.168.23.0/30Direct00D192.168.23.1Ethernet0/0/1
192.168.23.1/32Direct00D127.0.0.1Ethernet0/0/1
说明:查看路由表AR2没有AR3的路由条目,只有与AR1的e0/0/0接口相连的口学到路由条目
[AR3]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 5Routes : 5
Destination/MaskProtoPreCostFlags NextHopInterface
3.3.3.3/32Direct00D127.0.0.1LoopBack0
127.0.0.0/8Direct00D127.0.0.1InLoopBack0
127.0.0.1/32Direct00D127.0.0.1InLoopBack0
192.168.23.0/30Direct00D192.168.23.2Ethernet0/0/1
192.168.23.2/32Direct00D127.0.0.1Ethernet0/0/1
在AR3上查看也没有任何有关OSPF的路由条目
(3)要想让AR3能学到AR1与AR2发出的路由及AR2学到AR3发出的路由,可以:
在AR2将Hello时间改回原来默认的时间10s;或者在AR3上进入到e0/0/1接口视图下,用同样的方法将Hello时间改成与AR2的时间间隔一样是20s(AR3与AR2之间的接口是e0/0/1
)
四、思考与感想
1、在同一网段上的路由器,其Hellointerval和RouterDeadInterval必须分别一致,否则不能形成邻居关系。
2、在修改了Hello时间间隔时,同一网段路由器接口在没有重启的情况下,ospf信息多长时间就会失效,不建立邻居关系。
3、查找相关的资料理解DR与BDR的形成过程。这里只是提了一点点,未做过多的说明。