HCNA-33 理解OSPF Router-ID
<Huawei>display router id //查看路由ID RouterID:0.0.0.0 设备在未进行配置前默认路由ID为0.0.0.0· <Huawei>system-view [Huawei]sysnamer1 [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]ipaddress 172.16.12.1 24 [r1-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]ipaddress 192.168.10.1 24 [r1-GigabitEthernet0/0/1]interfaceloopback 0 [r1-LoopBack0]ipaddress 1.1.1.1 32 [r1-LoopBack0]quit [r1]displayip interface brief *down:administratively down ^down:standby (l):loopback (s):spoofing Thenumber of interface that is UP in Physical is 4 Thenumber of interface that is DOWN in Physical is 1 Thenumber of interface that is UP in Protocol is 4 Thenumber of interface that is DOWN in Protocol is 1 Interface IP Address/Mask Physical Protocol GigabitEthernet0/0/0 172.16.12.1/24 up up GigabitEthernet0/0/1 192.168.10.1/24 up up GigabitEthernet0/0/2 unassigned down down LoopBack0 1.1.1.1/32 up up(s) NULL0 unassigned up up(s) [r1]display router id RouterID:172.16.12.1 可以看到,当前设备上的全局Router ID是172.16.12.1,而不是Loopback接口地址,因为是接口配置顺序会影响Router ID的选举,设备上每一次配置的是GE 0/0/0的物理地址,所以该地址会被Router ID使用,后面就算是增加环回口地址也不会被使用了。同理如果第一次配置的是环回口地址,那么也会被Router ID使用。 下面undo掉GE0/0/0的地址: [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]undo ip address 172.16.12.1 24 [r1-GigabitEthernet0/0/0]quit [r1]displayrouter id RouterID:1.1.1.1 当删除当前使用的Router-ID地址后,便会触发重新选举,按照环回口优先的规则,选择使用1.1.1.1作为Router ID。 可以手工指定Router-ID,优点是不受选举地址的删除或变更影响。 <r1>system-view [r1]routerid 1.1.1.1 //配置Router-ID Info:Router ID has been modified, please reset the relative protocols manually toupdate the Router ID. 信息:路由器ID已被修改,请手动重置相关协议 更新路由器ID。 即当前全局配置的Router-ID已经被更新,如果目前设备上已经运行OSPF协议,需要重置OSPF协议进程或者重启整台路由器才可以使得OSPF协议中的Router-ID也同步更新使用该新的全局Router-ID。 <r1>resetospf process //重置OSPF进程 Warning:The OSPF process will be reset. Continue? [Y/N]:y 完成其余基本配置: <r1>system-view [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]ipaddress 172.16.12.1 24 <Huawei>system-view [Huawei]sysnamer2 [r2]interfaceGigabitEthernet 0/0/0 [r2-GigabitEthernet0/0/0]ipaddress 172.16.12.2 24 [r2-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r2-GigabitEthernet0/0/1]ipaddress 172.16.23.2 24 [r2-GigabitEthernet0/0/1]interfaceGigabitEthernet 0/0/2 [r2-GigabitEthernet0/0/2]ipaddress 172.16.24.2 24 [r2-GigabitEthernet0/0/2]interfaceloopback 0 [r2-LoopBack0]ipaddress 2.2.2.2 32 [r2-LoopBack0]quit <Huawei>system-view [Huawei]sysnamer3 [r3]interfaceGigabitEthernet 0/0/0 [r3-GigabitEthernet0/0/0]ipaddress 172.16.23.3 24 [r3-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r3-GigabitEthernet0/0/1]ipaddress 192.168.30.1 24 [r3-GigabitEthernet0/0/1]interfaceloopback 0 [r3-LoopBack0]ipaddress 3.3.3.3 32 [r3-LoopBack0]quit <Huawei>system-view [Huawei]sysnamer4 [r4]interfaceGigabitEthernet 0/0/0 [r4-GigabitEthernet0/0/0]ipaddress 172.16.24.4 24 [r4-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r4-GigabitEthernet0/0/1]ipaddress 192.168.40.1 24 [r4-GigabitEthernet0/0/1]interfaceloopback 0 [r4-LoopBack0]ipaddress 4.4.4.4 32 [r4-LoopBack0]quit 配置OSPF及OSPF私有Router-ID [r1]ospf1 router-id 1.1.1.1 //配置OSPF进程1 私有ID [r1-ospf-1]area0 [r1-ospf-1-area-0.0.0.0]network1.1.1.1 0.0.0.0 [r1-ospf-1-area-0.0.0.0]network192.168.10.0 0.0.0.255 [r1-ospf-1-area-0.0.0.0]network172.16.12.0 0.0.0.255 [r1-ospf-1-area-0.0.0.0]return [r2]ospf1 router-id 2.2.2.2 [r2-ospf-1]area0 [r2-ospf-1-area-0.0.0.0]network2.2.2.2 0.0.0.0 [r2-ospf-1-area-0.0.0.0]network172.16.12.0 0.0.0.255 [r2-ospf-1-area-0.0.0.0]network172.16.23.0 0.0.0.255 [r2-ospf-1-area-0.0.0.0]network172.16.24.0 0.0.0.255 [r2-ospf-1-area-0.0.0.0]return [r3]ospf1 router-id 3.3.3.3 [r3-ospf-1]area0 [r3-ospf-1-area-0.0.0.0]network3.3.3.3 0.0.0.0 [r3-ospf-1-area-0.0.0.0]network172.16.23.0 0.0.0.255 [r3-ospf-1-area-0.0.0.0]network192.168.30.0 0.0.0.255 [r3-ospf-1-area-0.0.0.0]return [r4]ospf1 router-id 4.4.4.4 [r4-ospf-1]area0 [r4-ospf-1-area-0.0.0.0]network4.4.4.4 0.0.0.0 [r4-ospf-1-area-0.0.0.0]network172.16.24.0 0.0.0.255 [r4-ospf-1-area-0.0.0.0]network192.168.40.0 0.0.0.255 [r4-ospf-1-area-0.0.0.0]return 测试连通性 : PC>ping192.168.40.100 Ping192.168.40.100: 32 data bytes, Press Ctrl_C to break From192.168.40.100: bytes=32 seq=1 ttl=125 time=31 ms From192.168.40.100: bytes=32 seq=2 ttl=125 time=16 ms From192.168.40.100: bytes=32 seq=3 ttl=125 time=15 ms From192.168.40.100: bytes=32 seq=4 ttl=125 time=32 ms From192.168.40.100: bytes=32 seq=5 ttl=125 time=31 ms ---192.168.40.100 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 15/25/32 ms 下面把R2的OSPF 私用Router-ID配置成与R3一样看一下会怎么样: <r2>system-view [r2]ospf1 router-id 3.3.3.3 [r2-ospf-1]return <r2>resetospf 1 process //重置OSPF协议进程1 <r2>displayospf peer brief OSPF Process 1 with Router ID 3.3.3.3 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/2 4.4.4.4 Full ----------------------------------------------------------------------------<r2>display ospf peer brief OSPF Process 1 with Router ID 3.3.3.3 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/2 4.4.4.4 Full ---------------------------------------------------------------------------- OSPF协议重新收敛之后,发现R2与R3之间的邻居关系消失。 再测试PC1与PC2的连通性: PC>ping192.168.30.100 Ping192.168.30.100: 32 data bytes, Press Ctrl_C to break Requesttimeout! Requesttimeout! Requesttimeout! Requesttimeout! Requesttimeout! ---192.168.30.100 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss 结果是网络不通,网络发生了故障,说明一个问题,验证了OSPF建立直连邻居关系时,Router-ID一定不能重叠。那么OSPF非直连邻居的Router-ID重叠会怎么样: 还原R2制造的问题,现在把R3的Router-ID改成与R4一样: [r2]ospf1 router-id 2.2.2.2 [r2-ospf-1]return <r2>resetospf 1 process Warning:The OSPF process will be reset. Continue? [Y/N]:y [r3]ospf1 router-id 4.4.4.4 [r3-ospf-1]return <r3>resetospf 1 process Warning:The OSPF process will be reset. Continue? [Y/N]:y <r2>displayospf peer brief OSPF Process 1 with Router ID 2.2.2.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 1.1.1.1 Full 0.0.0.0 GigabitEthernet0/0/1 4.4.4.4 Full 0.0.0.0 GigabitEthernet0/0/2 4.4.4.4 Full ---------------------------------------------------------------------------- 发现R2有两个4.4.4.4的邻居! <r2>displayip routing-table protocol ospf RouteFlags: R - relay, D - download to fib ------------------------------------------------------------------------------ Publicrouting table : OSPF Destinations : 4 Routes : 4 OSPFrouting table status : <Active> Destinations : 4 Routes : 4 Destination/Mask Proto Pre Cost Flags NextHop Interface 1.1.1.1/32 OSPF 10 1 D 172.16.12.1 GigabitEthernet 0/0/0 4.4.4.4/32 OSPF 10 1 D 172.16.24.4 GigabitEthernet 0/0/2 192.168.10.0/24 OSPF 10 2 D 172.16.12.1 GigabitEthernet 0/0/0 192.168.40.0/24 OSPF 10 2 D 172.16.24.4 GigabitEthernet 0/0/2 OSPFrouting table status : <Inactive> Destinations : 0 Routes : 0 发现此时R2的路由表OSPF条目中,并没有R3的路由条目,说明的问题是即使路由器邻居关系建立正常,但也无法获取到路由条目。
|