华为实验20-理解OSPF Router-ID

实验原理

一些动态路由协议需要router-id作为路由器的身份标识,如果启动这些路由协议没有指定router-id,那么路由协议进程将无法启动.
router-id选举规则为,如果通过router-id命令配置了router-id,就按照配置结果设置,按照配置的先后顺序
如果没有,若存在ip地址的lookback接口,则选择lookback接口中最大的地址作为router-id,
如果没有配置lookback,就从其他的接口中选择最大的ip地址作为router-id.
当且仅当被选为router-id的接口IP地址被删除修改,才触发重新选择过程,其他情况(接口处于down状态,已经选了一个非lookback的地址又配置了一个lookback接口地址,配置了一个更大的接口地址)不触发重新选择的过程.
router-id改变之后,各协议需要手工执行reset命令,才会重新选取新的router-id

实验目的

掌握选举规则
掌握ospf手动配置router-id的方法
理解ospf中router-id必须唯一的意义.

实验拓扑

在这里插入图片描述
1 配置ip并测试连通性
2在R1上使用display router id命令来查看当前设备上router-id

[R1]dis router id
RouterID:0.0.0.0

查看IP
在这里插入图片描述
因为先配置了物理接口,10.0.12.1,所以会被优先选为router-id,删除这个ip地址,会重新进行选举(router id删除可以重新选举).这时候,对应的

[R1]dis router id
RouterID:1.1.1.1

可以手动配置R1的router-id为1.1.1.1,这样的好处就是就算删除了这个lookback也不会触发重新选举.
2\理解ospf的router-id
在所有的路由器都配置ospf协议,并都运行在区域0内,使用ospf router-id命令来配置ospf协议的私有router-id,如果不配置,就会默认使用全局下的router-id/

[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.0.1.0 0.0.0.255

[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.0.23.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255

[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.0.23.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255

[R4]ospf 1 router-id 4.4.4.4
[R4-ospf-1]area 0
[R4-ospf-1-area-0.0.0.0]network 10.0.24.0 0.0.0.255
[R4-ospf-1-area-0.0.0.0]network 10.0.3.0 0.0.0.255

修改R2的router-id为3.3.3.3 使得r3和r2的router-id重叠,并重置协议进程使得配置生效.display current-configuration

[R2]ospf 1 router-id 3.3.3.3
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.
[R2-ospf-1]quit
[R2]quit
<R2>reset ospf process

发现R2和R3的ospf邻居状态消失

<R2>dis ospf peer

	 OSPF Process 1 with Router ID 3.3.3.3
		 Neighbors 

 Area 0.0.0.0 interface 10.0.12.2(GigabitEthernet0/0/0)'s neighbors
 Router ID: 1.1.1.1          Address: 10.0.12.1       
   State: Full  Mode:Nbr is  Slave  Priority: 1
   DR: 10.0.12.1  BDR: 10.0.12.2  MTU: 0    
   Dead timer due in 31  sec 
   Retrans timer interval: 5 
   Neighbor is up for 00:00:43     
   Authentication Sequence: [ 0 ] 

		 Neighbors 

 Area 0.0.0.0 interface 10.0.24.2(GigabitEthernet0/0/2)'s neighbors
 Router ID: 4.4.4.4          Address: 10.0.24.4       
   State: Full  Mode:Nbr is  Master  Priority: 1
   DR: 10.0.24.4  BDR: 10.0.24.2  MTU: 0    
   Dead timer due in 33  sec 
   Retrans timer interval: 5 
   Neighbor is up for 00:00:45     
   Authentication Sequence: [ 0 ] 

pc1和pc2 的无法通信,已经发生了网络故障,说明了ospf建立直连邻居关系的时候,router-id无法重叠,
在这里插入图片描述
如果和非直连的邻居的routerid重叠了会怎么样呢?
还原R2的配置,调整R4的id与R3 重叠

[R2]ospf 1 router-id 2.2.2.2
[R2]quit
<R2>reset ospf process

查看R2的邻居状态
在这里插入图片描述
调整R4的router id为3.3.3.3 与R3 重合

[R4]ospf router-id 3.3.3.3
Info: The configuration succeeded. You need to restart the OSPF process to valid
ate the new router ID.
[R4-ospf-1]quit
[R4]quit
<R4>reset ospf process

查看R2的邻居状态
在这里插入图片描述
发现R2又两个3.3.3.3的邻居


<R2>dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 2        Routes : 2        

OSPF routing table status : <Active>
         Destinations : 2        Routes : 2

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.1.0/24  OSPF    10   2           D   10.0.12.1       GigabitEthernet
0/0/0
       10.0.3.0/24  OSPF    10   2           D   10.0.24.4       GigabitEthernet
0/0/2

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

以上可以观察到 R2没有接收到R3上的.说明即使路由邻居建立正常,也无法正常获取路由条目.
r2认为是同一个ospf邻居,但是LSA不一致,造成链路状态数据库发送错误,无法计算出正确得路由信息.

  • 0
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值