OSPF建立邻接关系过程

一,要成功建立一个邻接关系需要四个阶段

1,邻居路由器发现阶段

2,双向通信阶段(bidirectional communication):互为邻居的路由器在它们的hello数据包中互相看到自己的R-ID (two-way)

3,数据库同步阶段(database synchronization):路由器之间交互DBD/LSR/LSU/LSA达到数据库同步。(选主从来控制数据包的交换)

4,完全邻接阶段(full adjacency)

二,建立邻居关系

1,成为邻居的条件

hello--type 1

除了*以外补充:1,始发路由器接口的掩码

             2,选项字段中的N/P、E标记位

A,修改了dead时间:

B,修改了area-ID

C,修改三层MTU:

使用接口下命令: ip ospf mtu-ignore (在MTU小的接口下敲)

三,创建邻接关系(相关的三个包)

1,Database Description:数据库描述--type 2

2,Link State Request:链路状态请求--type 3

3,Link State Update:链路状态更新--type 4

*4,Link State Acknowledgment:链路状态确认--type 5

OSPF建立邻接关系的条件:

             
Exstart/Exchange Stuck:
当最大传输单元(MTU)设置为相邻路由器接口不配比,问题发生。 如果路由器与更高的MTU发送MTU在相邻路由器设置的一个信息包更大,相邻路由器丢弃信息包。
Troubleshooting Commands:
 Sh int (interface-no>....This command will give you physical link parameter like link state,MTU(Which is imp factor in ospf while exchanging database and need to same on both site>.

Example:
Router#sh int fa0/0 | in MTU | up
FastEthernet0/0 is up, line protocol is up
  MTU 1500 bytes, BW 10000 Kbit/sec, DLY 1000 usec,

For MTU ,you need to check on (Routing) IP MTU that's will gonna stuck your OSPF process in ex-start state if both side device don't have same MTU , default both MTUs are same on IOS platform but you can change using "ip mtu" command under interface on the router and on Switch ,you can set system routing MTU.

Example:
Router#sh ip int fa0/0 | in MTU
  MTU is 1400 bytes
                             
two-way Stuck:
This is expected behavior on routers running OSPF. OSPF routers on multi-access segments synchronize their  databases with their Designated Router (DR) or a Backup Designated Router (BDR) only. The OSPF status between two routers transitions to Full only if at least one of them is a DR or a BDR.  The state remains Two-way between a pair of routers if both are DRothers.
For more information on the relationship between OSPF routers stuck in the two-way state, refer to Why Does the show ip ospf neighbor Command Reveal Neighbors Stuck in Two-Way State?

Troubleshooting Commands:

1) show ip ospf neighbors....This command will show you states of your neighbor and dead timer.

Example:

Router#sh ip os ne

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:38    10.1.1.1        FastEthernet0/0

1) Show ip ospf int brief ...This command will give you OSPF property briefly on each interface.

Example:

Router#sh ip os int bri
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs  F/C
Fa0/0        100   0                   10.1.1.2/24     10    BDR        1/1

3) Show ip ospf int <inteface no>...This command will give detail OSPF interface information like network-type,authentication type and key, interface mask,cost etc.

Example:

Router#sh ip os int fa0/0
FastEthernet0/0 is up, line protocol is up
  Internet Address 10.1.1.2/24, Area 0
  Process ID 100, Router ID 10.1.1.2, Network Type BROADCAST, Cost: 10
  Enabled by interface config, including secondary ip addresses
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 1.1.1.1, Interface address 10.1.1.1
  Backup Designated router (ID) 10.1.1.2, Interface address 10.1.1.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:06
  Supports Link-local Signaling (LLS)
  Cisco NSF helper support enabled
  IETF NSF helper support enabled
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 1.1.1.1  (Designated Router)
  Suppress hello for 0 neighbor(s)