OSPF多区域配置与心得理解

ospf 多区域

文章目录

  • ospf 多区域
      • 实验背景
      • 实验需求
      • 1.配置ip地址
      • 2.配置OSPF
      • 3查看R1,R4的邻居表
      • 4.强制发布一跳默认路由
        • 查看R1有没有收到默认路由
      • 5.在R3上使用静默接口
        • 测试PC ping外网6.6.6.6
      • 6.查看路由

实验背景

OSPF多区域配置与心得理解_第1张图片

实验需求

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

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

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

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

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

你可能感兴趣的:(网络工程师)