OSPF多區域配置與心得理解

懶惰會殺死你發表於2019-07-16

ospf 多區域

實驗背景

實驗需求

1.配置IP地址

2.完整配置ospf多區域

3.檢視鄰居關係

4.強制釋出預設路由

5.在R3的G0/0/1口配置靜默介面

6.驗證路由表

1.配置ip地址

R1

[R1]INT LOOPBACK 0
[R1-LoopBack0]IP ADDRESS 1.1.1.1 32
[R1]INT G 0/0/0
[R1-GigabitEthernet0/0/0]IP ADDRESS 20.0.0.1 30
[R1]INT G0/0/1
[R1-GigabitEthernet0/0/1]IP ADDRESS 10.0.0.1 30

R2

[R2]INT LOOPBACK 0
[R2-LoopBack0]IP ADDRESS 2.2.2.2 32
[R2]INT G0/0/1
[R2-GigabitEthernet0/0/1]IP ADDRESS 30.0.0.1 30
[R2]INT G0/0/0
[R2-GigabitEthernet0/0/0]IP ADDRESS 20.0.0.2 30
[R2]int loopback 1
[R2-LoopBack1]ip address 6.6.6.6 32

R3

[R3]INT LOOPBACK 0
[R3]IP ADDRESS 3.3.3.3 32
[R3-LoopBack0]INT G0/0/1
[R3-GigabitEthernet0/0/1]IP ADDRESS 10.0.0.2 30
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip address 192.168.1.1 24

R4

[R4]INT LOOPBACK 0
[R4-LoopBack0]IP ADDRESS 4.4.4.4 32
[R4]INT G0/0/1
[R4-GigabitEthernet0/0/1]IP ADDRESS 30.0.0.2 30

2.配置OSPF

R1

[R1]ospf
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 20.0.0.0 0.0.0.3
[R1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0]area 1
[R1-ospf-1-area-0.0.0.1]network 10.0.0.0 0.0.0.3

R2

[R2]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0]network 20.0.0.0 0.0.0.3
[R2-ospf-1]area 2
[R2-ospf-1-area-0.0.0.2]network 30.0.0.0 0.0.0.3

R3

[R3]ospf
[R3-ospf-1]area 1
[R3-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]network 10.0.0.0 0.0.0.3
[R3-ospf-1-area-0.0.0.1]network 3.3.3.3 0.0.0.0

R4

[R4]ospf
[R4-ospf-1]area 2
[R4-ospf-1-area-0.0.0.2]network 30.0.0.0 0.0.0.3
[R4-ospf-1-area-0.0.0.2]network 4.4.4.4 0.0.0.0

3檢視R1,R4的鄰居表

R1

[R1]dis 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             20.0.0.2         Full        
 0.0.0.1          GigabitEthernet0/0/1             10.0.0.2         Full        
 ----------------------------------------------------------------------------

可以看到route-id 不是4.4.4.4 應該是先建立鄰居的時候hollo裡面攜帶的是30.0.0.2 這個本地介面地址

R4

[R4]dis ospf peer brief 

	 OSPF Process 1 with Router ID 30.0.0.2
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.2          GigabitEthernet0/0/1             20.0.0.2         Full        

 ----------------------------------------------------------------------------

4.強制釋出一跳預設路由

後面帶了 always 無論路由器是否有預設路由 都可以釋出 如果沒有帶alwaye 那釋出之前本地必須要有一條預設路由。

但是我不建議這樣做 要分好情況 這樣做只是下發了一條 預設路由 但是本地不會生成預設路由 所以就沒有指明去外網的路 很有可以會出問題

R2

[R2-ospf-1]default-route-advertise always 

檢視R1有沒有收到預設路由

R1

<R1>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 17       Routes : 17       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   20.0.0.2        GigabitEthernet
0/0/0

5.在R3上使用靜默介面

如上配置 宣告瞭g0/0/0 那它就有了收發ospf報文的能力 但是0/0/0口接的是個主機完全不知道ospf hollo 報文 比較適合配置靜默介面

R3

[R3-ospf-1]silent-interface GigabitEthernet 0/0/0

測試PC ping外網6.6.6.6

PC

PC>ping 6.6.6.6

Ping 6.6.6.6: 32 data bytes, Press Ctrl_C to break
From 6.6.6.6: bytes=32 seq=1 ttl=253 time=62 ms
From 6.6.6.6: bytes=32 seq=2 ttl=253 time=16 ms
From 6.6.6.6: bytes=32 seq=3 ttl=253 time=31 ms
From 6.6.6.6: bytes=32 seq=4 ttl=253 time=16 ms
From 6.6.6.6: bytes=32 seq=5 ttl=253 time=31 ms

--- 6.6.6.6 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 16/31/62 ms

6.檢視路由

R1

<R1>DIS IP ROUTING
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 17       Routes : 17       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   20.0.0.2        GigabitEthernet
0/0/0
        1.1.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
        2.2.2.2/32  OSPF    10   1           D   20.0.0.2        GigabitEthernet
0/0/0
        3.3.3.3/32  OSPF    10   1           D   10.0.0.2        GigabitEthernet
0/0/1
        4.4.4.4/32  OSPF    10   2           D   20.0.0.2        GigabitEthernet
0/0/0
       10.0.0.0/30  Direct  0    0           D   10.0.0.1        GigabitEthernet
0/0/1
       10.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       10.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       20.0.0.0/30  Direct  0    0           D   20.0.0.1        GigabitEthernet
0/0/0
       20.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       20.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       30.0.0.0/30  OSPF    10   2           D   20.0.0.2        GigabitEthernet
0/0/0
      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
    192.168.1.0/24  OSPF    10   2           D   10.0.0.2        GigabitEthernet
0/0/1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

R2
可以看到R2裝置上沒有靜態預設路由

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.1/32  OSPF    10   1           D   20.0.0.1        GigabitEthernet
0/0/0
        2.2.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
        3.3.3.3/32  OSPF    10   2           D   20.0.0.1        GigabitEthernet
0/0/0
        4.4.4.4/32  OSPF    10   1           D   30.0.0.2        GigabitEthernet
0/0/1
        6.6.6.6/32  Direct  0    0           D   127.0.0.1       LoopBack1
       10.0.0.0/30  OSPF    10   2           D   20.0.0.1        GigabitEthernet
0/0/0
       20.0.0.0/30  Direct  0    0           D   20.0.0.2        GigabitEthernet
0/0/0
       20.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       20.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       30.0.0.0/30  Direct  0    0           D   30.0.0.1        GigabitEthernet
0/0/1
       30.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       30.0.0.3/32  Direct  0    0           D   127.0.0.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
    192.168.1.0/24  OSPF    10   3           D   20.0.0.1        GigabitEthernet
0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

R3

<R3>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 17       Routes : 17       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.0.0.1        GigabitEthernet
0/0/1
        1.1.1.1/32  OSPF    10   1           D   10.0.0.1        GigabitEthernet
0/0/1
        2.2.2.2/32  OSPF    10   2           D   10.0.0.1        GigabitEthernet
0/0/1
        3.3.3.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
        4.4.4.4/32  OSPF    10   3           D   10.0.0.1        GigabitEthernet
0/0/1
       10.0.0.0/30  Direct  0    0           D   10.0.0.2        GigabitEthernet
0/0/1
       10.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       10.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       20.0.0.0/30  OSPF    10   2           D   10.0.0.1        GigabitEthernet
0/0/1
       30.0.0.0/30  OSPF    10   3           D   10.0.0.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
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     GigabitEthernet
0/0/0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

R4

<R4>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   30.0.0.1        GigabitEthernet
0/0/1
        1.1.1.1/32  OSPF    10   2           D   30.0.0.1        GigabitEthernet
0/0/1
        2.2.2.2/32  OSPF    10   1           D   30.0.0.1        GigabitEthernet
0/0/1
        3.3.3.3/32  OSPF    10   3           D   30.0.0.1        GigabitEthernet
0/0/1
        4.4.4.4/32  Direct  0    0           D   127.0.0.1       LoopBack0
       10.0.0.0/30  OSPF    10   3           D   30.0.0.1        GigabitEthernet
0/0/1
       20.0.0.0/30  OSPF    10   2           D   30.0.0.1        GigabitEthernet
0/0/1
       30.0.0.0/30  Direct  0    0           D   30.0.0.2        GigabitEthernet
0/0/1
       30.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/1
       30.0.0.3/32  Direct  0    0           D   127.0.0.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
    192.168.1.0/24  OSPF    10   4           D   30.0.0.1        GigabitEthernet
0/0/1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

相關文章