OSPF的route-id选举

 OSPF路由器之间互相通告链路状态,因为这种情况,那么接收到链路状态的路由器必须要知道该链路状态是从哪台路由器发来的,如果不为路由器指定一个唯一的名字,那么路由器之间就无法确认各自的身份,那么在这种情况下通告链路状态是毫无意义的,所以我们必须给每一个OSPF路由器指定一个身份,那么这个就是 route-id ,这个route-id在网络中不可以重名,否则路由器从收到的链路状态当中就无法确定对方的网络位置,OSPF路由器在发出的链路状态中都会写上自己的 route-id

每台OSPF路由器只有一个 route-id ;route-id使用IP地址的形式标识,那么确定route-id的方式为:

1.手工指定 route-id

2.路由器上环回接口最大的IP地址被选为route-id,非活动接口的IP地址不可以被选为route-id

3.如果没有活动的环回接口,则会选择物理接口最大的IP地址作为 route-id

4.没有RID,就没办法启动OSPF进程

 

那么我们通过实验来证明上述结论

实验拓扑如下:

 

Router(config)#hostname R1

R1(config)#int lo 0

R1(config-if)#ip add 1.1.1.1 255.255.255.0          配置环回接口IP地址

R1(config-if)#no shut

R1(config-if)#exit

R1(config)#int f0/0

R1(config-if)#ip add 12.1.1.1 255.255.255.0         配置物理接口IP

R1(config-if)#no shut

R1(config-if)#exit

R1(config)#router ospf 100                          启动OSPF进程

R1(config-router)#net 1.1.1.0 0.0.0.255 area 0

R1(config-router)#net 12.1.1.0 0.0.0.255 area 0      宣告网段进入ospf

R1(config-router)#exit     

 

此时我们查看R1 route-id 

 

我们看到路由器R1的 route-id 为1.1.1.1

我们再看看R1上有哪些接口是开启的并配置了IP地址

 

我们看到了R1上有物理接口和环回口分别配置了IP地址,默认情况下 环回接口的IP地址被选举为 route-id

那么当有多个环回口地址之后,route-id如何进行选举呢? 我们对R1路由器的配置进行如下更改

 

R1(config)#int lo 1

R1(config-if)#ip add 4.4.4.4 255.255.255.0

R1(config-if)#no shut

R1(config-if)#int lo 2

R1(config-if)#ip add 3.3.3.3 255.255.255.0

R1(config-if)#no shut

 

此时我们再看  route-id 如何被选举

R1(config)#no router ospf 100

R1(config)#router ospf 100

R1(config-router)#net 12.1.1.0 0.0.0.255 area 0

R1(config-router)#exit

R1(config)#exit

R1#

R1#show ip protocols 

Routing Protocol is "ospf 100"

  Outgoing update filter list for all interfaces is not set 

  Incoming update filter list for all interfaces is not set 

  Router ID 4.4.4.4       此时我们发现 route-id被自动选举为环回接口的最大地址     

  Number of areas in this router is 1. 1 normal 0 stub 0 nssa

  Maximum path: 4

  Routing for Networks:

    12.1.1.0 0.0.0.255 area 0

  Routing Information Sources:  

    Gateway         Distance      Last Update 

  Distance: (default is 110)

R1#

 

手工指定的 route-id 优先级高于系统自行选择的 route-id

我们对R1路由器进行继续的配置

 

R1(config)#router ospf 100

R1(config-router)#route

R1(config-router)#router-id 12.1.1.1              手工指定 route-id 为12.1.1.1

R1(config-router)#exit

R1(config)#exit

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: y                 重启OSPF进程

R1#

R1#

R1#show ip protocols

Routing Protocol is "ospf 100"

  Outgoing update filter list for all interfaces is not set

  Incoming update filter list for all interfaces is not set

  Router ID 12.1.1.1          我们发现route-id发生变化,可见手工指定的rid优先级较高

  Number of areas in this router is 1. 1 normal 0 stub 0 nssa

  Maximum path: 4

  Routing for Networks:

    12.1.1.0 0.0.0.255 area 0

 Reference bandwidth unit is 100 mbps

  Routing Information Sources:

    Gateway         Distance      Last Update

  Distance: (default is 110)

 

R1(config)#no int lo 0

R1(config)#no int lo 1

R1(config)#no int lo 2   删除三个环回口

R1(config)#exit

 

R1#show ip inter b

Interface                  IP-Address      OK? Method Status                Protocol

FastEthernet0/0            unassigned      YES unset  administratively down down

FastEthernet1/0            12.1.1.1        YES manual up                    up

FastEthernet1/1            unassigned      YES unset  administratively down down

SSL***-VIF0                unassigned      NO  unset  up                    up

 

当前的活动接口只有 12.1.1.1

 

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: y           重启OSPF进程

R1#show ip protocols

Routing Protocol is "ospf 100"

  Outgoing update filter list for all interfaces is not set

  Incoming update filter list for all interfaces is not set

  Router ID 12.1.1.1                        此时我们发现 route-id发生了变化

  Number of areas in this router is 1. 1 normal 0 stub 0 nssa

  Maximum path: 4

  Routing for Networks:

    12.1.1.0 0.0.0.255 area 0

 Reference bandwidth unit is 100 mbps

  Routing Information Sources:

    Gateway         Distance      Last Update

  Distance: (default is 110)

 

继续为路由器R1配置一个物理接口IP地址,要大于12.1.1.1

 

 

R1(config)#int f0/0

R1(config-if)#ip add 23.1.1.1 255.255.255.0    为接口配置IP地址,但是不开启端口

 
 

 

R1#clear ip ospf process

Reset ALL OSPF processes? [no]: y

R1#

 

R1#show ip protocols

Routing Protocol is "ospf 100"

  Outgoing update filter list for all interfaces is not set

  Incoming update filter list for all interfaces is not set

  Router ID 12.1.1.1              我们发现Route-id没有发生变化

  Number of areas in this router is 1. 1 normal 0 stub 0 nssa

  Maximum path: 4

  Routing for Networks:

    12.1.1.0 0.0.0.255 area 0

 Reference bandwidth unit is 100 mbps

  Routing Information Sources:

    Gateway         Distance      Last Update

  Distance: (default is 110)

 
可见必须是活动的物理接口的IP地址才有可能被选举为 route-id
 
 
我们继续在路由器R2上进行实验
 

路由器R2上并没有配置任何的接口IP,此时启动OSPF进程会报错,提示路由器没有route-id 所以没办法启动OSPF进程

 

所以我们进行了如下归纳总结

1.路由器通过route-id来知道OSPF协议

2.链路状态数据库使用 route-id ,所以每个路由器之间必须有不同的route-id

3.默认情况下OSPF协议开启时,具有活跃端口的最大IP地址被选举为 route-id

4. 环回接口在选举route-id时具有较高优先级,如果环回接口存在,那么最大的环回接口IP被选举    为route-id

5. 在OSPF进城下 手工指定 route-id 

 

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值