Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39980
  • 博文数量: 28
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 440
  • 用 户 组: 普通用户
  • 注册时间: 2013-02-26 20:08
文章分类

全部博文(28)

文章存档

2013年(28)

我的朋友

分类: 网络与安全

2013-02-27 18:15:15

多区域OSPF

命令:

R1(config-router)#network 172.16.12.0 0.0.0.255 area 1        //通告172.16.12.0/24网段为区域1

R2(config-router)#network 172.16.23.0 0.0.0.255 area 0        //通告172.16.23.0/24网段为区域0

R3(config-router)#network 172.16.34.0 0.0.0.255 area 2        //通告172.16.34.0/24网段为区域2

R4(config-router)#redistribute connected subnets 

                                             //再发布直连但没有被通告网络的子网路由(172.16.4.0/24)

“redistribute connected subnets”命令:

①“redistribute connected”命令类似于“network”命令,但是被“redistribute connected”再发布进来

  的路由是外部路由,而被“network”通告的路由是本自治域系统内部的路由;

②“redistribute connected”命令只对没有进行子网划分的有类网络进行再发布,而“subnets”参数可以发

  布有类网络进行子网划分后的子网路由。

OSPF配置实验(二)
R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 172.16.1.0 0.0.0.255 area 1

R1(config-router)#network 172.16.12.0 0.0.0.255 area 1

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 172.16.12.0 0.0.0.255 area 1

R2(config-router)#network 172.16.23.0 0.0.0.255 area 0

R2(config-router)#network 172.16.2.0 0.0.0.255 area 0

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 172.16.23.0 0.0.0.255 area 0

R3(config-router)#network 172.16.3.0 0.0.0.255 area 0

R3(config-router)#network 172.16.34.0 0.0.0.255 area 2

R4(config)#router ospf 1

R4(config-router)#router-id 4.4.4.4

R4(config-router)#network 172.16.34.0 0.0.0.255 area 2

R4(config-router)#redistribute connected subnets
实验调试

R1/R2/R3#show ip route ospf

OSPF配置实验(二)
以上输出表明路由表中带“O”的路由是区域内的路由,带“O IA”的路由是区域间的路由,带“O E2”的路由是外部自治系统被重分布到OSPF中的路由。此外路由器R1、R2、R3上的“O E2”路由条目“172.16.4.0/24”的度量值都是20,这是“O E2”路由的特征,当把外部自治系统的路由重分布到OSPF中时,如果不设置度量值和类型,默认度量值是20,默认类型为“O E2”。
说明:OSPF的外部路由分为类型1(在路由表中用代码“E1”表示)和类型2(在路由表中用代码“E2”表示),它们计算外部路由度量值的方式不同:

① 类型1 (E1)——外部路径成本 + 数据包在OSPF网络所经过各链路成本;

② 类型2 (E2)——外部路径成本,即ASBR上的默认设置。

在重分布时可以通过“metric-type”参数设置是类型1或2,默认为metric-type 2;也可以通过“metric”参数设置外部路径成本,默认为20:

R4(config)#router ospf 1

R4(config-router)#redistribute connected subnets metric 50 metric-type 1

                                         //再发布直连但没有被通告网络的子网路由,开销为50,类型为1

OSPF配置实验(二)

以上输出表明路由器R1、R2、R3收到的路由条目“172.16.4.0/24”类型为“O E1”,而且度量值都是不同的。

R1/R2/R3/R4#show ip ospf database

OSPF配置实验(二)
以上输出结果包含了区域1的LSA1、3、4、5,区域0的LSA、1、3、4以及区域2的LSA1、3、5的链路状态信息。并且R1和R2的区域1,R2和R3的区域0,R3和R4的区域2的链路状态数据库完全相同。
说明:

①相同区域内的路由器具有相同的链路状态数据库,只是在虚链路的时候略有不同。

②命令“show ip ospf database”所显示的内容并不是数据库中存储的关于每条LSA的全部信息,而仅是LSA的

  头部信息。要看LSA的全部信息,需要在该命令后面跟详细的参数,如下表:

OSPF配置实验(二)

R4#show ip ospf

OSPF配置实验(二)

手动汇总

命令:

R2(config-router)#area 1 range 172.16.0.0 255.255.252.0        //区域间路由汇总

R3(config-router)#summary-address 192.168.0.0 255.255.252.0        //外部自治域系统路由汇总

说明:

①区域间路由汇总必须在ABR上配置;

②外部自治域系统路由汇总必须在ASBR上配置。

OSPF配置实验(二)

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 172.16.0.0 0.0.3.255 area 1

R1(config-rotuer)#network 172.16.12.0 0.0.0.255 area 1

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 172.16.12.0 0.0.0.255 area 1

R2(config-router)#network 172.16.23.0 0.0.0.255 area 0

R2(config-router)#network 172.16.2.0 0.0.0.255 area 0

R2(config-router)#area 1 range 172.16.0.0 255.255.252.0

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 172.16.23.0 0.0.0.255 area 0

R3(config-router)#summary-address 192.168.0.0 255.255.252.0

R3(config-router)#redistribute eigrp 1 subnets

R3(config)#router eigrp 1

R3(config-router)#network 192.168.34.0

R3(config-router)#no auto-summary

R3(config-router)#redistribute ospf 1 metric 1000 100 255 1 1500 //带宽、时延、可靠性、负载、MTU

R4(config)#router eigrp 1

R4(config-router)#network 192.168.34.0

R4(config-router)network 192.168.0.0 0.0.3.255

R4(config-router)#no auto-summary
实验调试

R2#show ip route ospf

OSPF配置实验(二)
以上输出表明路由器R2对R1的4条环回接口所在网络的OSPF路由汇总后,产生了一条指向Null0的路由,同时收到R3汇总的EIGRP的路由。因为是重分布进来的外部自治系统的路由,所以路由代码因为“O E2”。

R3#show ip route ospf

OSPF配置实验(二)
以上输出表明路由器R3对R4的4条环回接口所在网络的EIGRP路由汇总后,会产生一条指向Null0的路由,同时收到经路由器R2汇总的路由。由于是区域间路由汇总,所以路由代码为“O IA”。

 

虚链路

命令:

R2(config-router)#area 1 virtual-link 3.3.3.3        //启用虚链路

R3(config-router)#area 1 virtual-link 2.2.2.2

说明:

①虚链路要配置在穿越区域的两台ABR上;

②“area 1”为穿越的区域;

③“virtual-link 3.3.3.3”为对端ABR的RID,可通过“show ip ospf”查看本路由器的RID。

OSPF配置实验(二)

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 172.16.1.0 0.0.0.255 area 0

R1(config-router)#network 172.16.12.0 0.0.0.255 area 0

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 172.16.12.0 0.0.0.255 area 0

R2(config-router)#network 172.16.2.0 0.0.0.255 area 0

R2(config-router)#network 172.16.23.0 0.0.0.255 area 1

R2(config-router)#area 1 virtual-link 3.3.3.3

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 172.16.23.0 0.0.0.255 area 1

R3(config-router)#network 172.16.3.0 0.0.0.255 area 1

R3(config-router)#network 172.16.34.0 0.0.0.255 area 2

R3(config-router)#area 1 virtual-link 2.2.2.2

R4(config)#router ospf 1

R4(config-router)#router-id 4.4.4.4

R4(config-router)#network 172.16.34.0 0.0.0.255 area 2

R4(config-router)#network 172.16.4.0 0.0.0.255 area 2
实验调试

R1#show ip route ospf
OSPF配置实验(二)

以上输出表明路由器R4虽然不与主干区域相连,但经过在R2、R3上配置虚链路后,OSPF的全部区域已经互通。

R2/R3#show ip ospf virtual-link        //查看虚链路的连接状态和参数

OSPF配置实验(二)
R2/R3#show ip ospf

OSPF配置实验(二)

以上输出表明:虚链路需要配置在要穿越区域的两台ABR路由器(R2、R3)上;R2、R3的区域0多出来了一个虚链路的接口,即虚链路经过了R2、R3穿越区域1连接到了主干区域;R2、R3的区域1给出的信息说明了这两台路由器是虚链路的端点。

 

末梢区域和完全末梢区域
命令:

R1(config-router)#area 1 stub        //把区域1配置成末梢区域

R2(config-router)#area 1 stub

R3(config-router)#area 2 stub no-summary        //把区域2配置成完全末梢区域

R4(config-router)#area 2 stub

说明:

①启用末梢区域:“area 1 stub”命令需要在区域内的所有路由器上启用;

②启用完全末梢区域:“area 2 stub no-summary”命令只需要在ABR上启用,“area 2 stub”命令在区域内

  其它路由器上启用。“no-summary”参数可以阻止区域间的路由进入末梢区域,所以叫完全末梢区域。

OSPF配置实验(二)

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 172.16.1.0 0.0.0.255 area 1

R1(config-rotuer)#network 172.16.12.0 0.0.0.255 area 1

R1(config-rotuer)#area 1 stub

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 172.16.12.0 0.0.0.255 area 1

R2(config-router)#network 172.16.23.0 0.0.0.255 area 0

R2(config-router)#redistribute connected subnets        //再发布直连路由到OSPF区域

R2(config-router)#area 1 stub

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 172.16.23.0 0.0.0.255 area 0

R3(config-router)#network 172.16.3.0 0.0.0.255 area 0

R3(config-router)#network 172.16.34.0 0.0.0.255 area 2

R3(config-router)#area 2 stub no-summary

R4(config)#router ospf 1

R4(config-router)#network 172.16.34.0 0.0.0.255 area 2

R4(config-router)#network 172.16.4.0 0.0.0.255 area 2

R4(config-router)#area 2 stub

末梢区域和完全末梢区域需要满足以下条件:

①区域中只有一个出口;

②区域不需要作为虚链路的过渡区域;

③区域内没有ASBR;

④区域不是主干区域。

实验调试

R1#show ip route ospf

OSPF配置实验(二)
以上输出表明路由器R2重分布进来的环回接口所在网络的路由并没有在路由器R1的路由表中出现,说明末梢区域不接收类型5的LSA,也就是外部自治系统的路由;同时末梢区域1的ABR(R2)自动向该区域内传播度量值为1的“0.0.0.0/0”的默认路由;末梢区域可以接收区域间路由。

R4#show ip route ospf
OSPF配置实验(二)

以上输出表明在完全末梢区域2中,路由器R4的路由表中除了直连和区域内路由外,其余全部被默认路由代替,证明完全末梢区域不接收外部路由和区域间路由,只有区域内的路由和一条由ABR向该区域注入的默认路由。

R1/R2#show ip ospf

OSPF配置实验(二)

R3/R4#show ip ospf
OSPF配置实验(二) 

NSSA(非纯末梢)区域和完全非纯末梢区域

命令
NSSA(非纯末梢)区域:

R1(config-router)#area 1 nssa        //把区域1配置成NSSA区域

R2(config-router)#area 1 nssa default-information originate     //配置NSSA区域并注入默认路由

完全非纯末梢区域:

R1(config-router)#area 1 nssa

R2(config-router)#area 1 nssa no-summary        //把区域1配置成完全非纯末梢区域

OSPF配置实验(二)

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-rotuer)#network 172.16.12.0 0.0.0.255 area 1

R1(config-rotuer)#redistribute connected subnets

R1(config-rotuer)#area 1 nssa

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 172.16.2.0 0.0.0.255 area 0

R2(config-router)#network 172.16.12.0 0.0.0.255 area 1

R2(config-router)#network 172.16.23.0 0.0.0.255 area 0

R2(config-router)#area 1 nssa

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 172.16.23.0 0.0.0.255 area 0

R3(config-router)#redistribute eigrp 1 subnets        //再发布EIGRP路由到OSPF区域

R3(config-router)#router eigrp 1

R3(config-router)#redistribute ospf 1 metric 1000 100 255 1 1500       //再发布OSPF路由器到EIGRP中

R3(config-router)#network 192.168.34.0

R3(config-router)#no auto-summary

R4(config)#router eigrp 1

R4(config-router)#network 192.168.4.0

R4(config-router)#network 192.168.34.0

R4(config-router)#no auto-summary
实验调试

R1#show ip route ospf

OSPF配置实验(二)

以上输出表明区域间的路由是可以进入到NSSA区域的;但是在路由器R1的路由表中并没有出现在R3上把EIGRP重分布进来的路由,因此,说明LSA类型为5的外部路由不能在NSSA区域中传播,ABR也没有能力把类型5的LSA转换成类型7的LSA。

完全非纯末梢区域和NSSA区域注入默认路由说明:

① 如果不想在NSSA区域中出现区域间的路由,只需在ABR的路由器上配置NSSA区域时加上“no-summary”参数即

   可,这时ABR也会自动向NSSA区域注入一条“O*IA”的默认路由,配置如下:

   R2(config)#router ospf 1

   R2(config-router)#area 1 nssa no-summary

   R1#show ip route ospf
   OSPF配置实验(二)

② 本实验中,如果在路由器R2配置NSSA时没有加“no-summary”参数,那么对路由器R1来讲,EIGRP部分的路由

   是不可达的,为了解决此问题,在路由器R2上配置NSSA区域时加上“default-information originate”参数

   即可,此时ABR路由器R2会向NSSA区域注入一条“O*N2”的默认路由器,配置如下:

   R2(config)#router ospf 1

   R2(config-router)#area 1 nssa default-information originate

   R1#show ip route ospf
   OSPF配置实验(二)
   以上输出表明“default-information originate”参数会向NSSA区域注入一条“O*N2”的默认路由,但是并

   没有像“no-summary”参数那样阻止区域间的路由进入NSSA区域。

③ 如果在路由器R2配置NSSA时“no-summary”参数和“default-information originate”参数都、都同时加

   上,下所示

   R2(config)#router ospf 1

   R2(config-router)#area 1 nssa default-information originate no-summary

   R1#show ip route ospf
   OSPF配置实验(二)
   以上输出表明“O IA”路由优于“O N2”的路由。

R2#show ip route ospf
OSPF配置实验(二)
以上输出表明NSSA区域的路由代码为“O N2”或“O N1”。

R3#show ip route ospf
OSPF配置实验(二)
以上输出表明ABR路由器R2将类型7的LSA转换成类型5的LSA,并且扩散到路由器R3。

R2#show ip ospf database
OSPF配置实验(二)
以上输出结果表明,路由器R2的区域1的链路状态数据库中类型7的LSA和类型5的SLA并存。同时存在两条“0.0.0.0”的LSA,一条为类型3;另一条为类型7,但是路由器会把类型3的LSA放到路由表中。

R2#show ip ospf

OSPF配置实验(二)

阅读(761) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~