H3CSE路由篇



第二章:OSPF的基本配置和优化



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />



一,ospf的基本配置:



1, 启动ospf进程,并制定进程ID,默认为1



[R2]ospf 1 router-id 1.1.1.1(同时指定router-id)



2, 配置区域ID



[R2-ospf-1]area 0



3, 在指定网段的接口下使能ospf


[R2-ospf-1-area-0.0.0.0]net 12.0.0.0 0.0.0.255


 



 



二,ospf单区域的配置


<?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />  
  
R2:ospf 1 router-id 1.1.1.1 
 
  
      area 0.0.0.0 
 
  
         network 12.0.0.0 0.0.0.255
 
  
FR-SWITCHING:ospf 1 router-id 2.2.2.2 
 
  
      area 0.0.0.0 
 
  
      network 12.0.0.0 0.0.0.255


配置完成查看邻居状态:


[FR-SWITCHING-ospf-1]display ospf peer
 
  
 
   
 
 
  
                  OSPF Process 1 with Router ID 2.2.2.2
 
  
                        Neighbor Brief Information
 
   
  
 Area: 0.0.0.0        
 
  
 Router ID       Address         Pri Dead-Time Interface       State
 
  
 1.1.1.1         12.0.0.1        1   40        GE0/1/0         Full/DR


 



三,ospf多区域的配置



ospf网络号 ospf配置network_ci



在单区域的基础上配置RTB:area 0.0.0.1



      

network 23.0.0.0 0.0.0.255
 
  
    RTC:ospf 1 router-id 3.3.3.3 
 
  
          area 0.0.0.1 
 
  
              network 23.0.0.0 0.0.0.255


查看结果:[FR-SWITCHING]display ospf peer

OSPF Process 1 with Router ID 2.2.2.2
 
  
                        Neighbor Brief Information
 
   
  
 Area: 0.0.0.0        
 
  
 Router ID       Address         Pri Dead-Time Interface       State
 
  
 1.1.1.1         12.0.0.1        1   36        GE0/1/0         Full/DR
 
   
  
 Area: 0.0.0.1        
 
  
 Router ID       Address         Pri Dead-Time Interface       State
 
  
     3.3.3.3         23.0.0.3        1   37        GE0/1/1         Full/DR



产看ospf路由表项:



[RTC-ospf-1]display ospf routing 
 
  
 
   
 
 
  
         OSPF Process 1 with Router ID 3.3.3.3
 
  
                  Routing Tables 
 
  
 
   
 
 
  
 Routing for Network 
 
  
 Destination        Cost     Type    NextHop         AdvRouter       Area
 
  
 23.0.0.0/24        1        Transit 23.0.0.3        3.3.3.3         0.0.0.1
 
  
 12.0.0.0/24        2        Inter   23.0.0.2        2.2.2.2         0.0.0.1
 
  
 
   
 
 
  
 Total Nets: 2  
 
  
 Intra Area: 1  Inter Area: 1  ASE: 0  NSSA: 0



其中transit表示转发网络,inter表示区域间路由,stub表示末梢网络



 



四,ospf的网络类型:1,boardcast;2,NBMA;3,P2P;4,P2MP(cisco中存在第五种网络类型:点到多点非广播)



NBMA网络中的ospf配置:(此处只研究P2MP与NBMA环境下的ospf)



ospf网络号 ospf配置network_ci_02



1, 模拟帧中继交换机:


[FR-Switching]fr switching
 
  
[FR-Switching -serial0/2/0] interface Serial0/2/0
 
  
[FR-Switching serial0/2/0] link-protocol fr
 
  
[FR-Switching -serial0/2/0] fr interface-type dce
 
  
[FR-Switching -serial0/2/0] fr dlci 102
 
  
[FR-Switching -serial0/2/0] fr dlci 103
 
  
[FR-SWITCHING-serial0/2/0] fr dlci-switch 102 interface Serial0/2/1 dlci 201
 
  
[FR-SWITCHING-serial0/2/0] fr dlci-switch 103 interface Serial0/2/2 dlci 301
 
  
[FR-SWITCHING-serial0/2/1]link-protocol fr
 
  
[FR-SWITCHING-serial0/2/1] fr interface-type dce
 
  
[FR-SWITCHING-serial0/2/1] fr dlci-switch 201 interface Serial0/2/0 dlci 102
 
  
[FR-SWITCHING-serial0/2/1] fr dlci-switch 203 interface Serial0/2/2 dlci 302
 
  
[FR-SWITCHING-serial0/2/1] fr dlci 201
 
  
[FR-SWITCHING-serial0/2/1] fr dlci 203
 
  
[FR-SWITCHING-serial0/2/2] link-protocol fr
 
  
[FR-SWITCHING-serial0/2/2] fr interface-type dce
 
  
[FR-SWITCHING-serial0/2/2] fr dlci-switch 301 interface Serial0/2/0 dlci 103
 
  
[FR-SWITCHING-serial0/2/2] fr dlci-switch 302 interface Serial0/2/1 dlci 203
 
  
[FR-SWITCHING-serial0/2/2] fr dlci 301
 
  
[FR-SWITCHING-serial0/2/2] fr dlci 302


注:inverse arp可以自动解析每条虚链路连接的对端设备IP地址,若不关闭则会影响静态映射的实验效果



2, 在非帧中继交换机上配置(RTC、RTD同理)



[R2-serial0/2/0] interface Serial0/2/0
 
  
 [R2-serial0/2/0]link-protocol fr
 
  
[R2 -Serial0/2/0]undo fr inarp(关闭逆向地址解析协议)
 
  
        [R2-serial0/2/0]ip address 10.1.1.1 255.255.255.0



    3,配置ospf协议(FR-SWITCHING、RTC同理)


[R2] ospf 1 router-id 1.1.1.1 
 
  
        [R2-ospf-1] peer 10.1.1.2(只可以指定邻居接口地址,因为它存在dlci映射关系)
 
  
 [R2-ospf-1] peer 10.1.1.3
 
  
 [R2-ospf-1]area 0.0.0.0 
 
  
        [R2 -ospf-1-area-0.0.0.0] network 1.1.1.1 0.0.0.0 
 
  
 [R2 -ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255



查看邻居状态


[R2]display ospf peer
 
  
 
   
 
 
  
                  OSPF Process 1 with Router ID 1.1.1.1
 
  
                        Neighbor Brief Information
 
   
  
 Area: 0.0.0.0        
 
  
 Router ID       Address         Pri Dead-Time Interface       State
 
  
BDR
 
  
DR


查看接口网络类型:


[R2]display ospf interface Serial 0/2/0
 
   
  
 
   
 
 
  
         OSPF Process 1 with Router ID 1.1.1.1
 
  
                 Interfaces 
 
  
 
   
 
 
  
 Interface: 10.1.1.1 (Serial0/2/0)
 
  
NBMA
 
  
 Priority: 1
 
  
 Designated Router: 10.1.1.3
 
  
 Backup Designated Router: 10.1.1.2
 
  
Hello 30, Dead 120, Poll  120, Retransmit 5, Transmit Delay 1



由以上结果可以看出,FR网络的默认网络类型为NBMA



 



在NBMA网络中无法传递广播、组播报文,运行ospf时需发送单播建立邻居关系;



 



修改网络类型:



[R2-serial0/2/0] ospf timer hello 10
 
  
[R2-serial0/2/0] ospf timer dead 40
 
  
[R2-serial0/2/0] ospf network-type broadcast



修改网络类型为boardcast后,ospf便可以通过组播建立邻居关系,而不需要手动指定邻居。



 



五,环境下的ospf



P2MP并不是默认的网络类型,需通过强制更改NBMA网络类型为P2MP;P2MP网络上ospf可以通过组播报文进行邻居发现、建立于维护,需手动映射本地dlci与对端接口IP地址的映射通过广播方式发送hello报文



       配置实例:(RTC、RTD同理)



[R2-serial0/2/0] interface Serial0/2/0
 
  
 [R2-serial0/2/0]link-protocol fr
 
  
[FR-SWITCHING-Serial0/2/0]undo fr inarp(关闭逆向地址解析协议)
 
  
        [R2-serial0/2/0]ip address 10.1.1.1 255.255.255.0
 
  
        [R2-serial0/2/0]fr map ip 10.1.1.2 102 boardcast
 
  
        [R2-serial0/2/0]fr map ip 10.1.1.3 103 boardcast(配置静态映射,”boardcast”表示允许通过广播或者组播发送报文)
 
  
        [R2-serial0/2/0]ospf network-type P2MP
 
  
        [R2-serial0/2/0]ospf timer hello 30
 
  
        [R2-serial0/2/0]ospf timer dead 120(P2MP默认与NBMA相同)
 
  
        [R2] ospf 1 router-id 1.1.1.1
 
  
 [R2-ospf-1]area 0.0.0.0 
 
  
        [R2 -ospf-1-area-0.0.0.0] network 1.1.1.1 0.0.0.0 
 
  
 [R2 -ospf-1-area-0.0.0.0] network 10.1.1.0 0.0.0.255



      


转载于:https://blog.51cto.com/2885227/1021421