Ospf 在广播网络中建立邻居关系的详细过程 目的:观察在广播网络中,OSPF建立邻接关系的过程 拓扑及设备需求 拓扑: 图片1 设备需求:3台路由器,ios版本为12.2 需求:配置3台路由器的以太网接口,参与OSPF,使3台路由器建立邻接关系 参考答案&测试过程:
  
Ospf 在广播网络中建立邻居关系的详细过程

目的:观察在广播网络中,OSPF建立邻接关系的过程
拓扑及设备需求
        拓扑:
 

图片1

      设备需求:3台路由器,ios版本为12.2
需求:配置3台路由器的以太网接口,参与OSPF,使3台路由器建立邻接关系
参考答案&测试过程:
配置:
     R1(config)#interface e0
     R1(config-if)#ip address 10.1.1.1 255.255.255.0
     R1(config-if)#no shut
     R1(config-if)#router ospf 1
     R1(config-router)#network 10.1.1.1 0.0.0.0 area 0
     R2(config)#interface e0
     R2(config-if)#ip address 10.1.1.2 255.255.255.0
     R2(config-if)#no shut
     R2(config-if)#router ospf 1
     R2(config-router)#network 10.1.1.2 0.0.0.0 area 0
     R3(config)#interface e0
     R3(config-if)ip address 10.1.1.3 255.255.255.0
     R3(config-if)#no shut
     R3(config-if)#router ospf 1
     R3(config-if)#network 10.1.1.3 0.0.0.0 area 0
    

效果:
    1.使用show命令观察参与ospf的接口,及ospf建立邻接关系的过程
R1#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0          1     0               10.1.1.1/24        10    DROTH 2/2
R2#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0          1     0               10.1.1.2/24        10    BDR   2/2
Rack12R3#show ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Et0/0        1     0               10.1.1.3/24        10    DR    2/2
可以看到,在缺省情况下,各个路由器的接口优先级相同,所以选举DR、BDR时比较的是接口IP地址。R3作为DR,R2作为BDR,R1为DROTHER。
2.使用show命令关系ospf邻接关系
2R1#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.1.2          1   FULL/BDR        00:00:32    10.1.1.2        Ethernet0
10.1.1.3          1   FULL/DR         00:00:30    10.1.1.3        Ethernet0
R2#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.1.1          1   FULL/DROTHER    00:00:35    10.1.1.1        Ethernet0
10.1.1.3          1   FULL/DR         00:00:37    10.1.1.3        Ethernet0
R3#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
10.1.1.1          1   FULL/DROTHER    00:00:31    10.1.1.1        Ethernet0
10.1.1.2          1   FULL/BDR        00:00:36    10.1.1.2        Ethernet0
可以看到,在广播网络中,ospf建立邻接关系不需要管理员的干涉,而是自动建立的。
3.使用debug观察整个邻接关系的建立过程
R1#debug ip ospf event
*Mar  1 00:26:54.327: OSPF: Send hello to 224.0.0.5 area 0 . Ethernet0 from 10.
1.1.1   (为224.0.0.5为目的发送hello包,发现邻居)
*Mar  1 00:26:54.811: OSPF: Rcv hello from 10.1.1.2 area 0 from Ethernet0 10.1.1
.2      (接收到邻居10.1.1.2发送的hello包)
*Mar  1 00:26:54.815: OSPF: 2 Way Communication to 10.1.1.2 . Ethernet0, state
2WAY   (10.1.1.2的hello包中的邻居列表包含自己的Router ID)
*Mar  1 00:26:54.819: OSPF: Backup seen Event before WAIT timer . Ethernet0
*Mar  1 00:26:54.823: OSPF: DR/BDR election . Ethernet0
(2-Way状态后,广播网络需要选举DR、BDR)
*Mar  1 00:26:54.823: OSPF: Elect BDR 10.1.1.2
*Mar  1 00:26:54.827: OSPF: Elect DR 10.1.1.2
*Mar  1 00:26:54.827:        DR: 10.1.1.2 (Id)   BDR: 10.1.1.2 (Id)
*Mar  1 00:26:54.831: OSPF: Send DBD to 10.1.1.2 . Ethernet0 seq 0x116B opt 0x5
2 flag 0x7 len 32
*Mar  1 00:26:54.839: OSPF: End of hello processing
*Mar  1 00:26:54.843: OSPF: Rcv hello from 10.1.1.3 area 0 from Ethernet0 10.1.1
.3
*Mar  1 00:26:54.847: OSPF: 2 Way Communication to 10.1.1.3 . Ethernet0, state
2WAY
*Mar  1 00:26:54.851: OSPF: Neighbor change Event . interface Ethernet0
*Mar  1 00:26:54.851: OSPF: DR/BDR election . Ethernet0
*Mar  1 00:26:54.855: OSPF: Elect BDR 10.1.1.2
*Mar  1 00:26:54.855: OSPF: Elect DR 10.1.1.3
*Mar  1 00:26:54.859:        DR: 10.1.1.3 (Id)   BDR: 10.1.1.2 (Id)
*Mar  1 00:26:54.863: OSPF: Send DBD to 10.1.1.3 . Ethernet0 seq 0x4EC opt 0x52
 flag 0x7 len 32
*Mar  1 00:26:54.867: OSPF: Remember old DR 10.1.1.2 (id)
*Mar  1 00:26:54.871: OSPF: Neighbor change Event . interface Ethernet0
*Mar  1 00:26:54.871: OSPF: DR/BDR election . Ethernet0
*Mar  1 00:26:54.871: OSPF: Elect BDR 10.1.1.2
*Mar  1 00:26:54.875: OSPF: Elect DR 10.1.1.3
*Mar  1 00:26:54.879:        DR: 10.1.1.3 (Id)   BDR: 10.1.1.2 (Id)
(选举结果,若优先级相同,则IP地址大的为DR或BDR)
*Mar  1 00:26:54.879: OSPF: End of hello processing
(2-Way状态结束,开始发送DD包)
*Mar  1 00:26:54.887: OSPF: Rcv DBD from 10.1.1.2 . Ethernet0 seq 0x1345 opt 0x
52 flag 0x7 len 32  mtu 1500 state EXSTART
 (发送数据库描述包,确认同步的主从关系进入ExStart状态)
*Mar  1 00:26:54.891: OSPF: NBR Negotiation Done. We are the SLAVE
                         (协商完毕,IP地址低的为从)
*Mar  1 00:26:54.891: OSPF: Send DBD to 10.1.1.2 . Ethernet0 seq 0x1345 opt 0x5
2 flag 0x2 len 52
*Mar  1 00:26:54.899: OSPF: Rcv DBD from 10.1.1.3 . Ethernet0 seq 0x3B0 opt 0x5
2 flag 0x7 len 32  mtu 1500 state EXSTART
*Mar  1 00:26:54.903: OSPF: NBR Negotiation Done. We are the SLAVE
*Mar  1 00:26:54.907: OSPF: Send DBD to 10.1.1.3 . Ethernet0 seq 0x3B0 opt 0x52
 flag 0x2 len 52
*Mar  1 00:26:54.915: OSPF: Rcv DBD from 10.1.1.2 . Ethernet0 seq 0x1346 opt 0x
52 flag 0x3 len 92  mtu 1500 state EXCHANGE
(从10.1.1.2收到DD包,确认数据库是否相同,进入Exchange状态)
*Mar  1 00:26:54.919: OSPF: Send DBD to 10.1.1.2 . Ethernet0 seq 0x1346 opt 0x5
2 flag 0x0 len 32
*Mar  1 00:26:54.927: OSPF: Database request to 10.1.1.2
*Mar  1 00:26:54.927: OSPF: sent LS REQ packet to 10.1.1.2, length 36
(向10.1.1.2发送链路状态请求包,进入loading状态)
*Mar  1 00:26:54.999: OSPF: Rcv DBD from 10.1.1.3 . Ethernet0 seq 0x3B1 opt 0x5
2 flag 0x3 len 92  mtu 1500 state EXCHANGE
*Mar  1 00:26:55.003: OSPF: Send DBD to 10.1.1.3 . Ethernet0 seq 0x3B1 opt 0x52
 flag 0x0 len 32
*Mar  1 00:26:55.011: OSPF: Database request to 10.1.1.3
*Mar  1 00:26:55.015: OSPF: sent LS REQ packet to 10.1.1.3, length 36
*Mar  1 00:26:55.019: OSPF: Rcv DBD from 10.1.1.2 . Ethernet0 seq 0x1347 opt 0x
52 flag 0x1 len 32  mtu 1500 state EXCHANGE
*Mar  1 00:26:55.019: OSPF: Exchange Done with 10.1.1.2 . Ethernet0
*Mar  1 00:26:55.023: OSPF: Send DBD to 10.1.1.2 . Ethernet0 seq 0x1347 opt 0x5
2 flag 0x0 len 32
*Mar  1 00:26:55.035: OSPF: Synchronized with 10.1.1.2 . Ethernet0, state FULL
(进入Full状态,开始同步数据库)
*Mar  1 00:26:55.039: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.1.2 . Ethernet0 from
LOADING to FULL, Loading Done
*Mar  1 00:26:55.047: OSPF: Rcv DBD from 10.1.1.3 . Ethernet0 seq 0x3B2 opt 0x5
2 flag 0x1 len 32  mtu 1500 state EXCHANGE
*Mar  1 00:26:55.051: OSPF: Exchange Done with 10.1.1.3 . Ethernet0
*Mar  1 00:26:55.051: OSPF: Synchronized with 10.1.1.3 . Ethernet0, state FULL
*Mar  1 00:26:55.055: %OSPF-5-ADJCHG: Process 1, Nbr 10.1.1.3 . Ethernet0 from
LOADING to FULL, Loading Done
总结:在广播网络中,OSPF通过以组地址224.0.0.5为目的发送hello包,自动发现邻居,并选举DR、BDR,所有非DR与DR、BDR建立Full邻接关系,同步数据库
 
  来源: www.ccxx.net 作者: 甘在伟