cisco 单区域实现OSPFv2

cisco 单区域实现OSPFv2

开放最短路径优先(OSPF)协议是一种链路状态路由协议,一般用于同一个路由域内。

  • 实现步骤:
  1. 在接口启用OSPF
  2. 通配符掩码
  3. 配置被动接口
  4. 验证OSPF配置

以下是ospf拓扑

地址分配表

R1配置

R1(config)#router ospf 10                       //进程ID 
R1(config-router)#rou
R1(config-router)#router-id 1.1.1.1             //路由ID

注意:现在只是进入了ospf配置,并没有开启,所以现在要使用network命令来决定那些接口参与ospfv2区域的路由进程

所以我们下一步查看路由表来决定那些接口参与路由进程

R1(config-router)#do show ip rou                     //在配置模式下查看路由表

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 4 subnets, 3 masks
C       172.16.1.0/24 is directly connected, GigabitEthernet0/0
L       172.16.1.1/32 is directly connected, GigabitEthernet0/0
C       172.16.3.0/30 is directly connected, Serial0/0/0
L       172.16.3.1/32 is directly connected, Serial0/0/0
     192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.10.4/30 is directly connected, Serial0/0/1
L       192.168.10.5/32 is directly connected, Serial0/0/1

得知我们要参与路由进程的接口为s0/0/0、s0/0/1

所以到第二步计算通配符掩码

  • 通配符掩码位0:匹配地址中对应位的值
  • 通配符掩码位1:忽略地址中对应位的值

在通配符掩码中,反码为真

计算通配符掩码最简单的方法就是从255.255.255.255减去网络子网掩码

路由表中s0/0/0接口掩码30位,即255.255.255.252,255.255.255.255减去255.255.255.252结果为0.0.0.3

下一步就是network命令通告网络了

R1(config-router)#network 172.16.1.0 0.0.0.255 area 0                   //area跟接入域名
R1(config-router)#network 172.16.3.0 0.0.0.3 area 0
R1(config-router)#network 192.168.10.4 0.0.0.3 area 0

由于我们配置的是单域,所以我们配置同一域(0),我这里默认设置为0

最后就是配置被动接口了

启用了ospf的路由,默认情况下都会想所有直连接口发送Hello数据包以此来发现邻居,注意:这时直连接口状态为Init

我们必须知道,在被动接口上无法形成邻居关系的

PC机不需要和路由形成邻居关系,所以配置为被动接口

被动接口会阻止路由信息从指定接口发送出去。但是,从其他接口发出的路由信息仍将通告指定接口所属的网络。

R1(config)#router ospf 10
R1(config-router)#passive-interface g0/0                    //配置被动接口g0/0

使用show ip protocols检验ospf路由

R1#show ip protocols                                                

Routing Protocol is "ospf 10"                                          //进程id
  Outgoing update filter list for all interfaces is not set 
  Incoming update filter list for all interfaces is not set 
  Router ID 1.1.1.1                                                    //ospf的id
  Number of areas in this router is 1. 1 normal 0 stub 0 nssa
  Maximum path: 4
  Routing for Networks:    
    172.16.1.0 0.0.0.255 area 0                                        //通告网络
    172.16.3.0 0.0.0.3 area 0        
    192.168.10.4 0.0.0.3 area 0
  Passive Interface(s): 
    GigabitEthernet0/1                                                 //被动接口
  Routing Information Sources:  
    Gateway         Distance      Last Update 
    1.1.1.1              110      00:22:12                             //邻居信息
  Distance: (default is 110)

上面只是讲了一下R1单一的配置,R2、R3的脚本如下

R2!!!

R2(config)#router ospf 10
R2(config-router)#router-id 2.2.2.2
R2(config-router)#do show ip rou

Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 4 subnets, 3 masks
C       172.16.2.0/24 is directly connected, GigabitEthernet0/0
L       172.16.2.1/32 is directly connected, GigabitEthernet0/0
C       172.16.3.0/30 is directly connected, Serial0/0/0
L       172.16.3.2/32 is directly connected, Serial0/0/0
     192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.10.8/30 is directly connected, Serial0/0/1
L       192.168.10.9/32 is directly connected, Serial0/0/1

R2(config-router)#network 172.16.2.0 0.0.0.255 area 0
R2(config-router)#network 172.16.3.0 0.0.0.3 area 0
R2(config-router)#network 192.168.10.8 0.0.0.3 area 0
R2(config-router)#passive-interface g0/0

R3!!!

R3(config)#router ospf 10
R3(config-router)#router-id 3.3.3.3
R3(config-router)#do show ip rou

Gateway of last resort is not set

     192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.1.0/24 is directly connected, GigabitEthernet0/0
L       192.168.1.1/32 is directly connected, GigabitEthernet0/0
     192.168.10.0/24 is variably subnetted, 4 subnets, 2 masks
C       192.168.10.4/30 is directly connected, Serial0/0/0
L       192.168.10.6/32 is directly connected, Serial0/0/0
C       192.168.10.8/30 is directly connected, Serial0/0/1
L       192.168.10.10/32 is directly connected, Serial0/0/1

R3(config-router)#network 192.168.1.0 0.0.0.255 area 0
R3(config-router)#network 192.168.10.4 0.0.0.3 area 0
R3(config-router)#network 192.168.10.8 0.0.0.3 area 0
R3(config-router)#passive-interface g0/0

好啦,本期内容就分享到这里,我们下期见!

猜你喜欢

转载自blog.csdn.net/weixin_54223979/article/details/116033032