OSPF(一)基本概念和基础实验

网上这个博客写的挺好的。https://blog.51cto.com/13746824/2153847。不过,我总归要自己做,才能转化称自己的东西。

一 基本概念 

OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。

OSPF的路由器类型:

1·区域边界路由器(ABR:area border router):用来连接Area 0和其他区域的路由器。

2·内部路由器:保存自己区域的链路状态信息

3·自治边界路由器(ASBR:Autonomous System Boundary Router):用来连接OSPF的AS与外部其他非OSPF网络的路由器。

QQ截图20180802221220

 OSPF的两个组播地址:

224.0.0.5  负责宣告
224.0.0.6  负责监听发送

OSPF数据包和报文类型:

 OSPF的7个状态,也可以分为两个阶段

1·Down状态

2·Init状态

3· 2-Way状态

4·Exstart状态

5·Exchange状态

6·Loading状态

7·Full状态

QQ截图20180802213359

QQ截图20180802213914

LSA链路状态通告(Link-State Advertisement)类型:

 二 基本功能实验

组网拓扑:

 配置步骤:

# 配置Router A。

<RouterA> system-view

[RouterA] router id 10.2.1.1

[RouterA] ospf

[RouterA-ospf-1] area 0

[RouterA-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[RouterA-ospf-1-area-0.0.0.0] quit

[RouterA-ospf-1] area 1

[RouterA-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[RouterA-ospf-1-area-0.0.0.1] quit

[RouterA-ospf-1] quit

# 配置Router B。

<RouterB> system-view

[RouterB] router id 10.3.1.1

[RouterB] ospf

[RouterB-ospf-1] area 0

[RouterB-ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255

[RouterB-ospf-1-area-0.0.0.0] quit

[RouterB-ospf-1] area 2

[RouterB-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[RouterB-ospf-1-area-0.0.0.2] quit

[RouterB-ospf-1] quit

# 配置Router C。

<RouterC> system-view

[RouterC] router id 10.4.1.1

[RouterC] ospf

[RouterC-ospf-1] area 1

[RouterC-ospf-1-area-0.0.0.1] network 10.2.1.0 0.0.0.255

[RouterC-ospf-1-area-0.0.0.1] network 10.4.1.0 0.0.0.255

[RouterC-ospf-1-area-0.0.0.1] quit

[RouterC-ospf-1] quit

# 配置Router D。

<RouterD> system-view

[RouterD] router id 10.5.1.1

[RouterD] ospf

[RouterD-ospf-1] area 2

[RouterD-ospf-1-area-0.0.0.2] network 10.3.1.0 0.0.0.255

[RouterD-ospf-1-area-0.0.0.2] network 10.5.1.0 0.0.0.255

[RouterD-ospf-1-area-0.0.0.2] quit

[RouterD-ospf-1] quit

结果验证:

查看RouterA的OSPF邻居状态:

    

 查看RouterA的OSPF路由表:

 查看Router C:

 <RouterC>display ospf peer verbose
         OSPF Process 1 with Router ID 10.4.1.1
             Neighbors
  Area 0.0.0.1 interface 10.2.1.2(GigabitEthernet1/0/2)'s neighbors
Router ID: 10.2.1.1         Address: 10.2.1.1         GR State: Normal   
   State: Full  Mode: Nbr is slave  Priority: 1
   DR: 10.2.1.1  BDR: 10.2.1.2  MTU: 0   
   Options is 0x42 (-|O|-|-|-|-|E|-)
   Dead timer due in 36  sec
   Neighbor is up for 00:08:54   
   Authentication Sequence: [ 0 ]
   Neighbor state change count: 6   
   BFD status: Disabled

 RouterC是在其他设备都配置好后,最后进行OSPF相关配置的。配置的过程中在RouterA和RouterC之间抓包可以看到:

a) Router A发给RouterC的DB Description报文,将本地的LSA的摘要信息发给RouterC:

  

 b) 接着RouterC发出 LS Request报文给Router A,向对方请求本地所需的LSA。

     

  c) Router A发给Router C LS Update报文,将C所需的LSA发给C:

  

 d)Router C回应确认报文 LS Acknowledge:

 RouterC的LSDB(同RouterA的area 1的LSDB):

<RouterC>display ospf lsdb

                                                                          

         OSPF Process 1 with Router ID 10.4.1.1

                 Link State Database

                                

                         Area: 0.0.0.1

 Type      LinkState ID    AdvRouter       Age  Len   Sequence  Metric

 Router    10.2.1.1        10.2.1.1        1285 36    80000034  0  

 Router    10.4.1.1        10.4.1.1        1242 48    8000002F  0  

 Network   10.2.1.1        10.2.1.1        1277 32    8000002A  0  

 Sum-Net   10.3.1.0        10.2.1.1        1665 28    80000007  2  

 Sum-Net   10.5.1.0        10.2.1.1        1565 28    80000007  3  

 Sum-Net   10.1.1.0        10.2.1.1        1389 28    80000030  1   

 查看路由表:

<RouterC>dis ospf routing

                                                                       

         OSPF Process 1 with Router ID 10.4.1.1

                  Routing Table

                                                                        

 Routing for network

 Destination        Cost     Type    NextHop         AdvRouter       Area

 10.4.1.0/24        1        Stub    0.0.0.0         10.4.1.1        0.0.0.1

 10.3.1.0/24        3        Inter   10.2.1.1        10.2.1.1        0.0.0.1

 10.5.1.0/24        4        Inter   10.2.1.1        10.2.1.1        0.0.0.1

 10.1.1.0/24        2        Inter   10.2.1.1        10.2.1.1        0.0.0.1

 10.2.1.0/24        1        Transit 0.0.0.0         10.2.1.1        0.0.0.1

                                                                       

 Total nets: 5 

 Intra area: 2  Inter area: 3  ASE: 0  NSSA: 0

 想把完整的报文发上来,但应该不行。

猜你喜欢

转载自www.cnblogs.com/April-cloud/p/12332818.html