OSPF配置

OSPF配置_第1张图片
TIM截图20181109111218.jpg

配置R1 R2 R3各个接口ip

[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]IP address 10.0.13.1 24
[R1-GigabitEthernet0/0/0]QU
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.12.1 24    
[R1-GigabitEthernet0/0/1]qu
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 10.0.1.1 24
[R1-LoopBack0]qu
[R1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.13.1/24         up         up        
GigabitEthernet0/0/1              10.0.12.1/24         down       down      
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack0                         10.0.1.1/24          up         up(s)     
NULL0                             unassigned           up         up(s)     
[R2]interface GigabitEthernet 0/0/1 
[R2-GigabitEthernet0/0/1]ip address 10.0.12.2 24
[R2-GigabitEthernet0/0/1]qu
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 10.0.2.2 24    
[R2-LoopBack0]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              unassigned           down       down      
GigabitEthernet0/0/1              10.0.12.2/24         up         up        
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack0                         10.0.2.2/24          up         up(s)     
NULL0                             unassigned           up         up(s) 
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.0.13.2 24
[R3-GigabitEthernet0/0/0]qu
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 10.0.3.3 24
[R3-LoopBack0]qu
[R3]interface LoopBack 3
[R3-LoopBack3]ip address 172.16.0.1 24
[R3-LoopBack3]qu
[R3]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.13.2/24         up         up        
GigabitEthernet0/0/1              unassigned           down       down      
GigabitEthernet0/0/2              unassigned           down       down      
LoopBack0                         10.0.3.3/24          up         up(s)     
LoopBack3                         172.16.0.1/24        up         up(s)     
NULL0                             unassigned           up         up(s) 

开启ospf

在R1上面开启ospf

[R1]ospf 1 router-id 10.0.1.1 
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255 
[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 10.0.1.0 0.0.0.255

在R2上面开启ospf

[R2]ospf 1 router-id 10.0.2.2 
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255

在R2上面开启ospf

[R3]ospf 1 router-id 10.0.3.3
[R3-ospf-1]a    
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.0.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255

在R1上面查看邻居关系

[R1-ospf-1-area-0.0.0.0]display ospf peer brief 

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

在R2上面测试ospf路由

[R2-ospf-1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.0.1.1/32  OSPF    10   1           D   10.0.12.1       GigabitEthernet
0/0/1
       10.0.2.0/24  Direct  0    0           D   10.0.2.2        LoopBack0
       10.0.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
     10.0.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       10.0.3.3/32  OSPF    10   2           D   10.0.12.1       GigabitEthernet
0/0/1
      10.0.12.0/24  Direct  0    0           D   10.0.12.2       GigabitEthernet
0/0/1
      10.0.12.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
    10.0.12.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      10.0.13.0/24  OSPF    10   2           D   10.0.12.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

[R2-ospf-1]ping 10.0.12.2
  PING 10.0.12.2: 56  data bytes, press CTRL_C to break
    Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=1 ms
    Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=1 ms
    Reply from 10.0.12.2: bytes=56 Sequence=3 ttl=255 time=1 ms
    Reply from 10.0.12.2: bytes=56 Sequence=4 ttl=255 time=1 ms
    Reply from 10.0.12.2: bytes=56 Sequence=5 ttl=255 time=1 ms

  --- 10.0.12.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 1/1/1 ms

[R2-ospf-1]ping 10.0.3.3
  PING 10.0.3.3: 56  data bytes, press CTRL_C to break
    Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 10.0.3.3: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 10.0.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 10.0.3.3: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 10.0.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/30 ms

修改 OSPF hello 和 dead 时间参数

查看接口默认的hello dead 时间

[R1]display ospf interface GigabitEthernet 0/0/1

     OSPF Process 1 with Router ID 10.0.1.1
         Interfaces 


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

将GigabitEthernet0/0/1 的OSPF hello和dead时间分别修改为15秒和60秒。

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ospf timer hello 15
[R1-GigabitEthernet0/0/1]ospf timer dead 60
[R1-GigabitEthernet0/0/1]display ospf interface GigabitEthernet 0/0/1

     OSPF Process 1 with Router ID 10.0.1.1
         Interfaces 


 Interface: 10.0.12.1 (GigabitEthernet0/0/1)
 Cost: 1       State: DR        Type: Broadcast    MTU: 1500  
 Priority: 1
 Designated Router: 10.0.12.1
 Backup Designated Router: 10.0.12.2
 Timers: Hello 15 , Dead 60 , Poll  120 , Retransmit 5 , Transmit Delay 1 

修改hello dead时间后,端口接口由于时间配置不同将无法同步信息,导致其无法创建邻居关系,请对端接口的时间也进行更改。

OSPF 缺省路由发布

在R3上添加默认路由,并发布到ospf中

[R3]ip route-static 0.0.0.0 0.0.0.0 LoopBack 3
[R3]ospf 1
[R3-ospf-1]default-route-advertise

在R2中查看是否有默认路由出现

[R2-GigabitEthernet0/0/1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.0.12.1       GigabitEthernet
0/0/1
       10.0.1.1/32  OSPF    10   1           D   10.0.12.1       GigabitEthernet
0/0/1
       10.0.2.0/24  Direct  0    0           D   10.0.2.2        LoopBack0
       10.0.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
     10.0.2.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
       10.0.3.3/32  OSPF    10   2           D   10.0.12.1       GigabitEthernet
0/0/1
      10.0.12.0/24  Direct  0    0           D   10.0.12.2       GigabitEthernet
0/0/1
      10.0.12.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
    10.0.12.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
      10.0.13.0/24  OSPF    10   2           D   10.0.12.1       GigabitEthernet
0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

控制 OSPF DR/BDR 的选举

查看R1 GigabitEthernet 0/0/0接口角色

[R1]display ospf interface GigabitEthernet 0/0/0

     OSPF Process 1 with Router ID 10.0.1.1
         Interfaces 


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

查看R3 GigabitEthernet 0/0/0接口角色

[R3]display ospf interface GigabitEthernet 0/0/0

     OSPF Process 1 with Router ID 10.0.3.3
         Interfaces 


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

2个接口的ospf权重为1,根据router id来判断DR BDR角色,由于R1的值router id更小,R1的接口为DR

更改R1的ospf权重值

[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ospf dr-priority 100

更改R3的ospf权重值

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ospf dr-priority 200

默认情况下,DR/BDR的选举采用的是非抢占模式。路由器优先级修改后,不会自动重新选举DR。因此,需要重置R1和R3间的OSPF邻居关系。

先关闭然后再打开R1和R3上的Gigabit Ethernet 0/0/0接口,重置R1和R3间的OSPF邻居关系。

[R3-GigabitEthernet0/0/0]shutdown 
[R3-GigabitEthernet0/0/0]undo shutdown 

查看DR BDR

[R1-GigabitEthernet0/0/0]display ospf interface GigabitEthernet 0/0/0

     OSPF Process 1 with Router ID 10.0.1.1
         Interfaces 


 Interface: 10.0.13.1 (GigabitEthernet0/0/0)
 Cost: 1       State: BDR       Type: Broadcast    MTU: 1500  
 Priority: 100
 Designated Router: 10.0.13.2
 Backup Designated Router: 10.0.13.1
 Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1 
[R3-GigabitEthernet0/0/0]display ospf interface GigabitEthernet 0/0/0

     OSPF Process 1 with Router ID 10.0.3.3
         Interfaces 


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

你可能感兴趣的:(OSPF配置)