OSPF的配置

拓扑如下:

一.配置思路

1.基础ip地址配置

2.配置OSPF使其内网互通

3.配置STUB区域

4.配置NSSA区域

5.配置虚连接使两个不连续的骨干区域相连

6.在NSSA区域引入外部路由

7.配置区域认证

8.配置虚连接的区域认证

9.配置OSPF路由汇总

10.配置OSPF路由过滤

 

二.具体配置

1.基础ip地址配置

根据图中配置即可,交换机不用配置。每个路由器环回口地址都是x.x.x.x/32,以1路由器为例来说就是1.1.1.1/32。

2.配置OSPF使其内网互通

以1路由器为例,配置如下:(只需要将对应接口宣告进对应区域就好了,环回口也要)

ospf 1 router-id 1.1.1.1
 area 0.0.0.0
  network 1.1.1.1 0.0.0.0
  network 123.1.1.1 0.0.0.0
 area 0.0.0.1
  network 145.1.1.1 0.0.0.0


3.配置STUB区域

图中的AREA 2为STUB区域(同一个区域中所有路由器都要配置)

以3路由器为例:

ospf 1 router-id 3.3.3.3
 area 0.0.0.2
  stub     ---在ABR上,如果要配置为完全STBU区域,阻止3类LSA向STUB区域扩散的话,只需要在stub 后面加no-summary即可


4.配置NSSA区域

图中的AREA 3为STUB区域(同一个区域中所有路由器都要配置)

以2路由器为例:

ospf 1 router-id 2.2.2.2
 area 0.0.0.3
  nssa                     ---在ABR上,如果要配置为完全STBU区域,阻止3类LSA向STUB区域扩散的话,只需要在nssa 后面加no-summary即可

5.配置虚连接使两个不连续的骨干区域相连

 

图中两个area 0 没有完全连接,使用vlink连接起来:

vlink配置的话是在两个没有完全连接的区域中间的那个区域中配置的(相当于中介)

4路由器:

ospf 1
 area 0.0.0.1
  vlink-peer 1.1.1.1         ---指定对端虚连接的路由器的router-id

1路由器:

ospf 1
 area 0.0.0.1
  vlink-peer 4.4.4.4         ---指定对端虚连接的路由器的router-id

查看vlink是否起来:

[1]display ospf vlink

     OSPF Process 1 with Router ID 1.1.1.1
         Virtual Links

 Virtual-link Neighbor-id  -> 4.4.4.4, Neighbor-State: Down
 Interface: <Unknown>
 Cost: 0  State: Down  Type: Virtual
 Transit Area: 0.0.0.1
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 Smart-discover: enable
 GR State: Normal

上面表示vlink连接失败

[1-ospf-1-area-0.0.0.1]display ospf vlink

     OSPF Process 1 with Router ID 1.1.1.1
         Virtual Links

 Virtual-link Neighbor-id  -> 4.4.4.4, Neighbor-State: Full

 Interface: 145.1.1.1 (GigabitEthernet0/0/1)
 Cost: 1  State: P-2-P  Type: Virtual
 Transit Area: 0.0.0.1
 Timers: Hello 10 , Dead 40 , Retransmit 5 , Transmit Delay 1
 Smart-discover: enable
 GR State: Normal

上面full状态表示vlink正常

6.在NSSA区域引入外部路由

area 3 是NSSA区域

在8和9路由器中引入10的环回口0

在此之前,先要在8和9中配置通往10的loopback0地址的静态路由

8路由器中:

ip route-static 10.10.10.10 255.255.255.255 10.1.1.10

9路由器中:

ip route-static 10.10.10.10 255.255.255.255 10.1.2.10

再在10中配置两条默认路由指向8和9路由器:

ip route-static 0.0.0.0 0.0.0.0 10.1.1.9
ip route-static 0.0.0.0 0.0.0.0 10.1.2.8

正片开始:

在8和9中引入静态路由:

 import-route static               ---两边这样配置的话,就是负载分担,如果想要一主一备的话就是要设置其中一台cost大一点为备。    ( import-route static cost 2000)

在12路由器中可以看到引入的外部路由:

[12]display  ospf routing

 

 Routing for ASEs
 Destination        Cost      Type       Tag         NextHop         AdvRouter
 10.10.10.10/32     2000      Type2      1           124.1.1.4       2.2.2.2

测试是否能通:

[12]ping -a 12.12.12.12 10.10.10.10
  PING 10.10.10.10: 56  data bytes, press CTRL_C to break
    Request time out
    Reply from 10.10.10.10: bytes=56 Sequence=2 ttl=251 time=170 ms
    Reply from 10.10.10.10: bytes=56 Sequence=3 ttl=251 time=120 ms
    Reply from 10.10.10.10: bytes=56 Sequence=4 ttl=251 time=110 ms
    Reply from 10.10.10.10: bytes=56 Sequence=5 ttl=251 time=120 ms

  --- 10.10.10.10 ping statistics ---
    5 packet(s) transmitted
    4 packet(s) received
    20.00% packet loss
    round-trip min/avg/max = 110/130/170 ms

7.配置区域认证

以area 0 为例:

1、2、3路由器:(配置都一样)

ospf 1
 area 0.0.0.0
  authentication-mode md5 1 cipher admin@123
 

抓包能看到认证字段:(因为OSPF报文没有认证字段,认证信息在OSPF的报文头部,所有OSPF需要对每一个,每一类OSPF报文都进行认证)

 8.配置虚连接的区域认证

以1路由器为例:(4路由器配置一样)

ospf 1
 area 0.0.0.1
  vlink-peer 4.4.4.4  simple cipher admin123

9.配置OSPF路由汇总

在5路由器中新增3个环回口地址,并将其宣告进OSPF进程中:

interface LoopBack1
 ip address 5.0.0.1 255.255.255.255
 ospf enable 1 area 0.0.0.1
#
interface LoopBack2
 ip address 5.0.0.2 255.255.255.255
 ospf enable 1 area 0.0.0.1
#
interface LoopBack3
 ip address 5.0.0.3 255.255.255.255
 ospf enable 1 area 0.0.0.1

我们在2路由器中可以看到新增的3条路由条目:

[2]display  ospf routing

     OSPF Process 1 with Router ID 2.2.2.2
          Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 3.3.3.3/32         1     Stub       123.1.1.3       123.1.1.3       0.0.0.0
 4.4.4.4/32         2     Inter-area 123.1.1.1       4.4.4.4         0.0.0.0
 5.0.0.1/32         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0
 5.0.0.2/32         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0
 5.0.0.3/32         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0

 5.5.5.5/32         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0

这时候我们在1路由上进行路由汇总看看:

[1-ospf-1-area-0.0.0.0]a 1
[1-ospf-1-area-0.0.0.1]abr-summary 5.0.0.0 255.255.255.240

此时2路由条目中又多了一条5.0.0.0/28的路由条目:

[2]display ospf routing

     OSPF Process 1 with Router ID 2.2.2.2
          Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 2.2.2.2/32         0     Stub       2.2.2.2         2.2.2.2         0.0.0.0
 123.1.1.0/24       1     Transit    123.1.1.2       2.2.2.2         0.0.0.0
 200.1.1.0/24       1     Transit    200.1.1.2       2.2.2.2         0.0.0.3
 1.1.1.1/32         1     Stub       123.1.1.1       1.1.1.1         0.0.0.0
 3.3.3.3/32         1     Stub       123.1.1.3       123.1.1.3       0.0.0.0
 4.4.4.4/32         2     Inter-area 123.1.1.1       4.4.4.4         0.0.0.0
 5.0.0.0/28         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0
 5.0.0.1/32         3     Inter-area 123.1.1.1     
  4.4.4.4         0.0.0.0
 5.0.0.2/32         3     Inter-area 123.1.1.1      
4.4.4.4         0.0.0.0
 5.0.0.3/32         3     Inter-area 123.1.1.1      
4.4.4.4         0.0.0.0
 5.5.5.5/32         2     Inter-area 123.1.1.1       1.1.1.1         0.0.0.0

既然配置了路由汇总就是让路由条目变少的,怎么现在反而多了一条呢。

哎。不用急,我们仔细看通告的路由器是不是变了。5.0.0.0/28是由1.1.1.1通告的,剩下几条是其他路由器通告的!!!

 

10.配置OSPF路由过滤

上面4.4.4.4不是通告了3条路由条目吗,我不想接受5.0.0.3/32的路由怎么办?

这时候路由过滤就派上用场了!!!

OSPF的路由过滤有三种:接口下/ospf进程中/ospf区域中

1.接口下(在接口下使用ospf filter-lsa-out命令进行LSA过滤)

2.ospf进程中(在OSPF进程中使用filter import命令对LSA进行过滤)

3.ospf区域中(通过filter命令调用acl或者ip-prefix进行路由过滤)

以第三种为例:

在1路由器下:

ip ip-prefix 3 deny 5.0.0.3 32   --定义一个前缀列表

[1-ospf-1]a 1
[1-ospf-1-area-0.0.0.1]filter  ip-prefix  3 import     --在area 1的入方向应用

  • 4
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值