OSPF动态路由协议⑤

扩展配置:

1,手工认证

        在OSPF数据包交互中,邻居之间的数据报中将携带认证口令,两边认证口令相同,则意味着身份合法。OSPF的手工认证总共分为三种:

接口认证:

        相当于在接口上配置接口认证,并需要对端的接口使用相同的接口认证才能建立关系

在R1的g0/0/0接口做md5认证,密文为1,密码为123456(密文传输)
[r1-GigabitEthernet0/0/0]ospf authentication-mode  md5 1 cipher  123456

//此时R1已经产生OSPF翻滚,此时没有R1的邻居关系
[r1-GigabitEthernet0/0/0]display  ospf   peer  brief 

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 ----------------------------------------------------------------------------

//此时需要去R2的对应接口设置相同的加密
[r2-GigabitEthernet0/0/0]ospf  authentication-mode  md5  1 cipher  123456

//此时R1已经可以刷出邻居表
<r1>display   ospf peer  brief 

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------

        此时为R1接口加密而R2没有加密的hello包 

         此为R2也使用相同的加密后的hello包(此时双方均已经进行了OFPF连接)        

 区域认证:

        本质还是接口认证,相当于将该路由器的该区域的所有激活的接口都配置了接口认证。(这个区域的其他路由器也同样需要进行配置)

//此时在R2上进行配置区域认证
[r2-ospf-1-area-0.0.0.1]authentication-mode  md5   2  plain  123456

//在R3上也进行AREA1的区域认证
[r3-ospf-1-area-0.0.0.1]authentication-mode  md5  2 plain  123456

//在R4上也进行AREA1的区域认证
[r4-ospf-1-area-0.0.0.1]authentication-mode  md5  2 plain  123456

//此时在R3上重新刷出邻居表
[r3-ospf-1-area-0.0.0.1]display   ospf  peer  brief 

	 OSPF Process 1 with Router ID 3.3.3.3
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.1          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.1          GigabitEthernet0/0/1             4.4.4.4          Full        
 ----------------------------------------------------------------------------

虚链路认证:

        虚链路认证建立在虚链路的过程中的认证,本质上其实也是接口认证。

//建立虚链路
[r2-ospf-1-area-0.0.0.1]vlink-peer  4.4.4.4
[r4-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2

//此时R5可以刷出到区域1和0的路由表

//此时设置虚链路加密为md5,密文为3,密码为123456
[r4-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2  md5 3 cipher  123456

//R5无法刷出到区域0和1的路由信息

//再去R2上设置相同的虚链路加密
[r2-ospf-1-area-0.0.0.1]vlink-peer 4.4.4.4 md5  3 cipher  123456

//此时R5已经可以刷出到区域0和1的信息

2,加快收敛(修改OSPF相关计时器)

[r1-GigabitEthernet0/0/0]display ospf interface g0/0/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: BDR       Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.2
 Backup Designated Router: 1.0.0.1
 Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 

hello时间:

        hello时间有两种。一般BMA,P2P网络的hello时间为10S;NBMA和PTMP网络的hello时间为30s。而如果hello时间修改,dead时间会自动按照4倍hello时间进行匹配修改

     #邻居之间如果hello时间和dead时间不匹配则无法建立邻居关系

//修改hello时间为20s
[r1-GigabitEthernet0/0/0]ospf timer hello 20

//此时再去查看接口的hello和daad时间
[r1-GigabitEthernet0/0/0]display ospf  interface  g0/0/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: BDR       Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.2
 Backup Designated Router: 1.0.0.1
 Timers: Hello 20 , Dead 80 , Poll  120 , Retransmit 5 , Transmit Delay 1


//由于hello时间不匹配无法建立邻居关系
[r1-GigabitEthernet0/0/0]display ospf peer brief

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 ----------------------------------------------------------------------------

dead时间:

        dead时间有两种。一般BMA,P2P网络的dead时间为40S;NBMA和PTMP网络的hello时间为120s。如果dead时间修改,hello时间并不会自动匹配修改
    #如果邻居之间hello时间和dead时间不相同,则无法建立邻居关系

//修改R1的g0/0/0接口的死亡时间为80s
[r1-GigabitEthernet0/0/0]ospf timer dead  80

//此时再去查看接口的信息。已经修改
[r1-GigabitEthernet0/0/0]display ospf interface g0/0/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: DR        Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.1
 Backup Designated Router: 0.0.0.0
 Timers: Hello 20 , Dead 80 , Poll  120 , Retransmit 5 , Transmit Delay 1 

//此时仍然无法建立邻居表
[r1-GigabitEthernet0/0/0]display ospf peer brief

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 ----------------------------------------------------------------------------


//此时重新修改为hello时间10s,dead时间为40s,重新刷出邻居表(默认可以只修改为hello时间)
[r1-GigabitEthernet0/0/0]ospf timer hello 10
[r1-GigabitEthernet0/0/0]display ospf interface g0/0/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: DR        Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.1
 Backup Designated Router: 0.0.0.0
 Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1 

//此时刷出邻居表
[r1-GigabitEthernet0/0/0]display ospf peer brief

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------

等待时间:

        OSPF还有一个waiting time:等待计时器(跟死亡时间长短一样,但是不显示)

        作用:在进行NMA网络的DR/BDR选举时,会有一个默认的选举时间而这个时间就是等待计时时间

轮询时间:

        POLL:轮询时间(120s)

        作用:本地路由对状态为down的邻居发送hello包的周期时间 。而POLL时间只在NBMA网络中起作用。因为NBMA网络中需要指定邻居关系(建立DR关系),而如果在等待时间过去以后,NBMA网络仍然没有建立邻居关系,则此时会进入down状态。NBMA默认的hello包的周期时间为30s(在waiting时间没有结束之前),而如果超过了等待时间,则本地路由器会每120s发送hello包

重传时间:

        Retransmit:重传时间(默认5s)

        当本地设备发送数据报等待对端确认时,而对端在重传时间内没有回复确认包,则本地会重新发送数据(所以为什么会多次发送LSU信息,而LACK只会确认最新的数据)

//修改R1的重传等待时间
[r1-GigabitEthernet0/0/0]ospf  timer retransmit  10

//再去查看本地接口的时间信息
[r1-GigabitEthernet0/0/0]display  ospf  interface g0/00/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: BDR       Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.2
 Backup Designated Router: 1.0.0.1
 Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 10 , Transmit Delay 1 

//此时修改等待时间,邻居表是不会断开的
[r1-GigabitEthernet0/0/0]display ospf  peer  brief 

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------

延迟时间:

        Transmit Delay:传输延迟(默认1s)。本地LSDB发送LSA信息时,需要从本地数据库中找出这条LSA信息,并打包发送给对端的LSDB,而LSA信息在发送过程中计时器是不会进行计时作用的。所以会在打包过程中算上这个时间

        作用:补偿在传输过程中的损耗时间,所以在打包过程中默认加上延迟的时间

//修改传输延迟时间
[r1-GigabitEthernet0/0/0]ospf trans-delay 5

//此时查看这个接口的传输信息
[r1-GigabitEthernet0/0/0]display ospf interface g0/00/0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Interfaces 


 Interface: 1.0.0.1 (GigabitEthernet0/0/0)
 Cost: 1       State: BDR       Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 1.0.0.2
 Backup Designated Router: 1.0.0.1
 Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 10 , Transmit Delay 5 

//此时会发现,传输时间的修改是不影响邻居关系的建立
[r1-GigabitEthernet0/0/0]display ospf peer brief

	 OSPF Process 1 with Router ID 1.1.1.1
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------

3,沉默接口

        OSPF的沉默接口会对单播包和组播包生效,所以不能和RIP一样结合单播邻居一样应用在一些特殊场景

        作用:使这个接口只接受而不发送OSPF数据

[r1-ospf-1]silent-interface  g0/0/1

4,缺省路由

        OSPF中的缺省路由总共可以分为三类:

①三类缺省:

        三类缺省是无法手工产生,只有在特殊区域中自动产生。普通stub区域,完全stub区域和完全nssa区域会产生三类缺省

        特点:类型为OSPF 优先级默认:10

②五类缺省:

        五类缺省可以通过命令可以手工配置,实际是将本地路由表中其他协议产生的缺省路由重发布到OSPF网络中。通过五类LSA携带,而五类缺省的配置需要本地路由存在有一条缺省路由。

         特点:类型为O_ASE,默认优先级为150

//在R1上配置一条缺省指向环回0
[r1]ip route-static 0.0.0.0   0  LoopBack  0

//配置五类缺省
[r1]ospf 1 router-id  1.1.1.1
[r1-ospf-1]default-route-advertise 

//五类缺省作为域外信息的导入,此时在R3上查看路由表(为域外信息)
<r3>display   ip routing-table  protocol  ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 7        Routes : 7        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   2.0.0.1         GigabitEthernet
0/0/0
        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.5.1/32  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1

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

        如果本地路由表中没有其他协议产生的缺省路由,可以通过增加always进行强制下发

//此时不用写缺省信息直接配置
[r4-ospf-1]default-route-advertise always 

//此时再去R3上查看五类LSA(之前的R1开销值比R3大,所以选择R3)
<r3>display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 7        Routes : 7        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.5.1/32  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1

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

③七类缺省:

        可以通过特殊区域自动生成/配置手工命令进行配置获取(和五类一样)
        七类缺省特点:类型为O_NSSA,默认优先级为150

5,路由过滤

        OSPF可以直接针对3类,5类,7类LSA进行过滤

        其中3类LSA为在ABR上操作,5类和7类是在ASBR上进行操作。过滤结果(在区域内仍然可以学习到该路由信息,但这个路由信息无法被区域外的路由学习到),过滤的信息包括环回,直连路由等明细路由

        3类路由汇总

//此时在R1上增加两个环回
[r1]interface  l  1
[r1-LoopBack1]ip address 192.169.1.1 24
[r1-LoopBack1]int l  2
[r1-LoopBack2]ip address  192.169.2.1  24

//此时再R1的OSPF上进行宣告
[r1]ospf  1 router-id  1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.169.0.0 0.0.255.255

//此时R3的路由表上查看192.169.1.0和192.169.2.0信息
<r3>display  ip routing-table  protocol  ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 8        Routes : 8        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.5.1/32  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.169.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.169.2.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0

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


//路由过滤掉192.169.1.0信息   需要在区域的ABR上进行操作
[r2-ospf-1-area-0.0.0.0]abr-summary 192.169.1.0 255.255.0.0 not-advertise 


//此时R3无法刷出192.169.0.0的信息
<r3>display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 6        Routes : 6        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.5.1/32  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1

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

         5类LSA过滤

//此时在R4上对五类的LSA进行过滤(作用:过滤到R5的环回路由信息)
[r4-ospf-1]asbr-summary  192.168.5.0  255.255.0.0  not-advertise

//此时在R3上查看路由信息,此时无法刷出到R5的环回
<r3>display ip routing-table protocol  ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 5        Routes : 5        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1

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

6,路由控制

         路由控制主要有两种方法,一种为修改优先级,另一种为修改开销值

//此时R3作为中心的路由,同时收到两边的路由条目
<r3>display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 8        Routes : 10       

OSPF routing table status : <Active>
         Destinations : 8        Routes : 10

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  OSPF    10   2           D   3.0.0.2         GigabitEthernet
0/0/1
       10.0.0.0/30  O_ASE   150  1           D   2.0.0.1         GigabitEthernet
0/0/0
       56.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   2           D   2.0.0.1         GigabitEthernet
0/0/0
                    OSPF    10   2           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.2.1/32  OSPF    10   1           D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  O_ASE   150  1           D   2.0.0.1         GigabitEthernet
0/0/0
                    O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
   192.168.44.1/32  OSPF    10   1           D   3.0.0.2         GigabitEthernet
0/0/1

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

①优先级

        通过修改优先级可以影响路由的选路情况,但只会影响本地路由表的路由条目优先级,很显然修改优先级只能说在修改本地路由表对于不同协议的优先级选择(尤其是域外)

        修改1类,2类,3类LSA的OSPF路由优先级

//此时在R4上修改ospf的优先级为51
[r4]ospf  1  router-id 4.4.4.4
[r4-ospf-1]preference 51

//查看本地的OSFP路由表
[r4-ospf-1]display  ip routing-table  protocol  ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 7        Routes : 7        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    51   3           D   3.0.0.1         GigabitEthernet
0/0/0
        2.0.0.0/30  OSPF    51   2           D   3.0.0.1         GigabitEthernet
0/0/0
       10.0.0.0/30  O_ASE   150  1           D   3.0.0.1         GigabitEthernet
0/0/0
       56.0.0.0/30  O_ASE   150  1           D   4.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    51   1           D   4.0.0.2         GigabitEthernet
0/0/1
    192.168.2.1/32  OSPF    51   2           D   3.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  O_ASE   150  1           D   4.0.0.2         GigabitEthernet
0/0/1

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

        修改5类,7类LSA的OSPF的路由优先级

//再在R4上修改域外的路由信息优先级为52
[r4-ospf-1]preference ase  52

//此时从150变成52
[r4-ospf-1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 7        Routes : 7        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    51   3           D   3.0.0.1         GigabitEthernet
0/0/0
        2.0.0.0/30  OSPF    51   2           D   3.0.0.1         GigabitEthernet
0/0/0
       10.0.0.0/30  O_ASE   52   1           D   3.0.0.1         GigabitEthernet
0/0/0
       56.0.0.0/30  O_ASE   52   1           D   4.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    51   1           D   4.0.0.2         GigabitEthernet
0/0/1
    192.168.2.1/32  OSPF    51   2           D   3.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  O_ASE   52   1           D   4.0.0.2         GigabitEthernet
0/0/1

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

②开销值

        开销值=参考带宽/真实带宽   

        修改参考带宽和真实带宽不能直接影响环回接口的开销值,所以只能通过修改开销值来影响选路

        A.通过修改参考带宽来修改开销值

        参考带宽一旦被修改,则所有的接口都会变化,并且要求网络中所有设备的参考带宽都修改成一样的。虽然可以影响开销值,但是并不适合影响选路(华为设备默认的参考带宽为100M)

        在带宽越来越大的环境中,修改参考带宽的意义会越来越大,因为参考带宽过小可能会造成选路不佳的情况
[r4-ospf-1]bandwidth-reference 1000
Info: Reference bandwidth is changed. Please ensure that the reference bandwidth
 that is configured for all the routers are the same.

        B.通过修改真实带宽,影响接口开销值(修改真实的链路带宽)

         接口的传输速率只能改小,不能改大。 通过修改接口的传输速率,是可以影响OSPF选路的,但是,因为他会导致接口的传输速率变低(因为接口速率只能改小),所以,并不建议使用这种方法来干涉选路。
[r4-GigabitEthernet0/0/0]speed  ?
  10    10M port speed mode
  100   100M port speed mode
  1000  1000M port speed mode

        C.直接修改接口的开销值(直接修改环回接口的开销值)

        OSPF开销值的结算方式是按照流量流入接口的开销来计算。所以在修改链接环路时,两边都要修改

        域外路由开销值是通过E type来决定的(此时需要去修改E type+种子度量值来修改域外的开销值)

//在R1的方向的入接口设置开销值为100
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ospf  cost  100

//在R4的方向的入接口设置开销值为120
[r3-GigabitEthernet0/0/0]int  g0/0/1
[r3-GigabitEthernet0/0/1]ospf  cost  120

//再去查看OSPF路由表
[r3]display  ip routing-table protocol  ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 8        Routes : 8        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.0.0.0/30  OSPF    10   101         D   2.0.0.1         GigabitEthernet
0/0/0
        4.0.0.0/30  OSPF    10   121         D   3.0.0.2         GigabitEthernet
0/0/1
       10.0.0.0/30  O_ASE   150  1           D   2.0.0.1         GigabitEthernet
0/0/0
       56.0.0.0/30  O_ASE   150  1           D   3.0.0.2         GigabitEthernet
0/0/1
    192.168.1.1/32  OSPF    10   101         D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.2.1/32  OSPF    10   100         D   2.0.0.1         GigabitEthernet
0/0/0
    192.168.4.1/32  O_ASE   150  1           D   2.0.0.1         GigabitEthernet
0/0/0
   192.168.44.1/32  OSPF    10   120         D   3.0.0.2         GigabitEthernet
0/0/1

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

OSPF的选路原则:

1.域内比较

        域内主要是1类和2类LSA的比较

        如果学到的路由是通过1类,2类LSA获取的域内路由:直接比较开销值。

        优先选择开销值小的路由,如果两条路由的开销值相同,则负载均衡

2.域间比较

        域间主要是三类LSA的比较

        如果学到的路由都是通过3类LSA学到的域间路由:直接比较开销值。

        优先选择开销值小的路由,如果两条路由的开销值相同,则负载均衡

3.域外比较

        域外主要是5类和7类LSA的比较

        如果学到的路由是通过5类LSA获取的域内路由:此时会涉及E TYPE(种子开销值的结算方式)和沿途开销值。

E TYPE比较:

        ①如果是E TYPE1    则传递的是度量值种子度量值+沿途累加度量值

        ②如果是E TYPE2    则传递的是度量值种子度量值

        ③如果在E TYPE 1和E TYPE 2之间存在一个优选规则,默认类型1永远优于类型2(如果类型1的开销值大,也选择使用类型1的那条线路)

如果是E TYPE 2则:

        ①优先比较种子度量值,并选择种子度量值小的

        ②如果种子开销值相同,则比较沿途开销,选择沿途开销值小的

        ③如果两条LSA5/7到达的沿途开销也相同,则负载均衡

如果是E TYPE 1则:

        ①优先比较总开销值(种子度量值+沿途开销值),并选择总开销值小的

        ②如果总开销值相同,则负载均衡

4.不同类型的LSA之间的比较

     ①域内和域间:域内路由(通过1.2.3类LSA学到的)优先级高于域间路由(通过3类LSA学到的)

     ②域间和域外:域间路由优先级(通过3类LSA学到的)高于域外路由(通过5类,7类LSA学到)

     ③5类和7类LSA:可以看成一种,5类LSA和7类LSA开销值相同,则负载均衡

SPF算法:

        最短路由优先算法,本地路由在区域内选择到达其他路由的最优解.

        ①本地路由先选择能直达的其他路由(本区域内)

        ②此时在已到达的路由中,选择开销值最小的下一跳路由,并罗列出它的直达(除起始路由)

        ③此时如果存在一个到达到目前已知存在的路由(使用新线路到达相同的路由),则比较累加开销值,选择开销值小的

        ④不断重复之前的②,③步骤,直到所有的开销值全部罗列出来,此时可以画出一条树状图(树状图则存在最短路由)

 

 四种类型的网络,转化为拓扑信息:

        1.P2P类型

        P2P类型存在两种表示方式:

                ①两边的接口在相同网段(指向相同的网段)

 

                ②两边的接口在不同网段(指向不同的网段)

 

        2.NMBA

                NMBA去的网段是存在开销值,而回来的网段不存在开销(一条网段的开销是相同的)

         3.环回类型

                使用默认开销值(指向一个环回网段)

 

OSPF防环机制:

域间防环:

        ①首先,星型拓扑的区域划分规则就是一种防环手段(区域围绕中心骨干,且彼此之间不直连)

        ②区域之间存在水平分割机制,区域水平分割(从该区域中学到的,将不再发送到该区域)

域内防环:

        由于OSPF区域内部传递的时拓扑信息,需要通过SPF算法计算路由条目,所以,域内的防环主要依靠SPF算法:最短路径优先 算法

        OSPF实际使用的算法是:I-SPF。而I-SPF算法是SPF的一个改进版本,改进点在于可以基于部分LSA的变更信息来进行部分运算,可以提高运算效率。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值