EqLlyHJ5w6,694hQRgLWm
华三实验大全之OSPF篇(IPv4)华三实验大全之OSPF篇(IPv4) 实验目录: 1.OSPF多区域基本配置 2.OSPF创建虚链路 3.OSPF引入外部路由 4.OPPF中的stub区域 5.OSPF中的stub no-summary区域 6.OSPF中的NSSA区域 一.OSPF多区域基本配置 按照上面的拓扑配置ip地址 宣告网络 R1上的lo0和s0/2/0宣告到区域1中。 [R1]ospf [R1-ospf-1]area 1 [R1-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255 [R1-ospf-1-area-0.0.0.1]network 1.1.1.0 0.0.0.255 [R1-ospf-1-area-0.0.0.1]q R2上的s0/2/0宣告到区域1中。 其他宣告到区域0中 [R2]ospf [R2-ospf-1]area 1 [R2-ospf-1-area-0.0.0.1]network 192.168.1.0 0.0.0.255 [R2-ospf-1-area-0.0.0.1]q [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]q [R2-ospf-1]q R3上的s0/2/0宣告到区域0中 S0/2/2和lo0宣告到区域2中 [R3]ospf [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [R3-ospf-1]area 2 [R3-ospf-1-area-0.0.0.2]net 192.168.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.2]net 3.3.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.2]q [R3-ospf-1]q R4上的s0/2/0宣告到区域2中 Lo0宣告到区域3中 [R4]ospf [R4-ospf-1]area 2 [R4-ospf-1-area-0.0.0.2]net 192.168.3.0 0.0.0.255 [R4-ospf-1-area-0.0.0.2]q [R4-ospf-1]area 3 [R4-ospf-1-area-0.0.0.3]net 4.4.4.0 0.0.0.255 [R4-ospf-1-area-0.0.0.3]q 基本的多区域OSPF已经配置完毕 查看一下R1的路由,是不能学习到区域3的路由的,因为区域3不与主干区域相连! [R1]display ip routing-table protocol ospf Public Routing Table : OSPF Summary Count : 6 OSPF Routing table Status : < Active> Summary Count : 4 Destination/Mask Proto Pre Cost NextHop Interface 2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0 3.3.3.3/32 OSPF 10 3124 192.168.1.2 S0/2/0 192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0 192.168.3.0/24 OSPF 10 4686 192.168.1.2 S0/2/0 OSPF Routing table Status : < Inactive> Summary Count : 2 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0 192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0 上面输出显示,我们没有学习到area3的路由4.4.4.0 几个查看命令 [R1]display ospf routing OSPF Process 1 with Router ID 1.1.1.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.3.0/24 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1 3.3.3.3/32 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1 2.2.2.2/32 1562 Inter 192.168.1.2 2.2.2.2 0.0.0.1 1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1 192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1 192.168.2.0/24 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1 Total Nets: 6 Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0 [R1]display ospf interface OSPF Process 1 with Router ID 1.1.1.1 Interfaces Area: 0.0.0.1 IP Address Type State Cost Pri DR BDR 1.1.1.1 PTP Loopback 1 1 0.0.0.0 0.0.0.0 192.168.1.1 PTP P-2-P 1562 1 0.0.0.0 0.0.0.0 解决不能学到区域3的路由的方法是:创建虚链路 二.OSPF创建虚链路 实验拓扑同实验一 vlink-peer 命令用来创建并配置一条虚连接,undo vlink-peer 命令用来删除一条已 有的虚连接。 根据 RFC2328 的规定,OSPF 的区域必须是和骨干区域保持连通的,可以使用 vlink-peer 命令建立逻辑上的连通性。在某种程度上,可以将虚连接看做一个普通 的使能了OSPF 的接口,因为在其上配置的hello、retransmit 和trans-delay 等参数 的原理是类似的。 需要注意的是,当配置虚连接验证时,由骨干区域的authentication-mode 命令来 确定使用的验证类型是MD5 密文验证或是明文验证。 相关配置可参考命令 authentication-mode 和display ospf。 注意: 全部是在area 2上做的 [R1]display ospf routing OSPF Process 1 with Router ID 1.1.1.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.3.0/24 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1 4.4.4.4/32 4686 Inter 192.168.1.2 2.2.2.2 0.0.0.1 3.3.3.3/32 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1 2.2.2.2/32 1562 Inter 192.168.1.2 2.2.2.2 0.0.0.1 1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1 192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1 192.168.2.0/24 3124 Inter 192.168.1.2 2.2.2.2 0.0.0.1 Total Nets: 7 Intra Area: 2 Inter Area: 5 ASE: 0 NSSA: 0 上面的输出可以看出,区域1已经可以学习到区域3的路由! 三.OSPF引入外部路由 实验拓扑 引入路由简介 import-route 命令用来引入外部路由信息,undo import-route 命令用来取消对外 部路由信息的引入。 如果引入类型为 1 的外部路由,则在路由表中,metric 值为本路由器到达广播此条 外部路由的路由器的metric 值加上引入时使用的cost 值。如果引入类型2 的外部路 由,则路由表中的metric 值就是引入时设定的cost 值。 此命令不是累加形式,cost、type、tag 等参数应在同一条命令中一次设定,否则后 配置的命令会覆盖先配置的命令。 缺省情况下,不引入其它协议的路由信息。 我们在R3上做一条通往R4的静态路由,R4向R3上做一条默认路由 [R3]ip route-static 4.4.4.0 24 192.168.3.2 [R4]ip route-static 0.0.0.0 0 192.168.3.1 引入外部静态路由和直连路由 [ 如果不引入直连路由的话,我们会学习不到R3直连的192.168.3.0网段 查看下面的路由,我们就可以看到外部路由的标志 [R1]display ip routing-table protocol ospf Public Routing Table : OSPF Summary Count : 9 OSPF Routing table Status : < Active> Summary Count : 7 Destination/Mask Proto Pre Cost NextHop Interface 2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0 3.3.3.3/32 O_ASE 150 1 192.168.1.2 S0/2/0 4.4.4.0/24 O_ASE 150 1 192.168.1.2 S0/2/0 192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0 192.168.2.1/32 O_ASE 150 1 192.168.1.2 S0/2/0 192.168.3.0/24 O_ASE 150 1 192.168.1.2 S0/2/0 192.168.3.2/32 O_ASE 150 1 192.168.1.2 S0/2/0 OSPF Routing table Status : < Inactive> Summary Count : 2 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0 192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0 四.OPPF中的stub区域 实验拓扑同实验三 注意: 如果要将一个区域配置成 Stub 区域,则该区域中的所有路由器都必须配置此属性。 相关配置可参考命令 default-cost。 把区域1配置为stub区域 末节区域过滤4,5类lsa,没有过滤3类lsa,所以有ospf区域内的所有路由条目。 外部路由走默认路由! [R1]display ip routing-table protocol ospf Public Routing Table : OSPF Summary Count : 5 OSPF Routing table Status : < Active> Summary Count : 3 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/0 OSPF 10 1563 192.168.1.2 S0/2/0 2.2.2.2/32 OSPF 10 1562 192.168.1.2 S0/2/0 192.168.2.0/24 OSPF 10 3124 192.168.1.2 S0/2/0 OSPF Routing table Status : < Inactive> Summary Count : 2 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 OSPF 10 0 1.1.1.1 Loop0 192.168.1.0/24 OSPF 10 1562 192.168.1.1 S0/2/0 五.OSPF中的stub no-summary区域 实验拓扑同实验三 简介: 完全末节区域是末节区域的升级,添加了过滤3类lsa功能,所以内部的路由也被汇总成为一条默认的路由。 注意: 完全末节区域不需要区域内的路由都开启stub no-summary ,但其他的路由器要开启stub 比如此实验, R1不必开启stub no-summary,但必须开启stub R2必须开启stub no-summary 过滤3,4,5类LSA,而且SAR会产生一条默认路由,到区域0的也走默认路由 使用“display ospf lsdb”可以清楚的看出! [R1]display ospf routing OSPF Process 1 with Router ID 1.1.1.1 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 0.0.0.0/0 1563 Inter 192.168.1.2 2.2.2.2 0.0.0.1 1.1.1.1/32 0 Stub 1.1.1.1 1.1.1.1 0.0.0.1 192.168.1.0/24 1562 Stub 192.168.1.1 1.1.1.1 0.0.0.1 Total Nets: 3 Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0 完全末节区域是末节区域的升级,添加了过滤3类lsa功能,所以内部的路由也被汇总成为一条默认的路由。上面的输出可以看出,已经学习不到其他区域的路由了,取而代之的是一条默认路由! [R1]display ip routing-table Routing Tables: Public Destinations : 7 Routes : 7 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/0 OSPF 10 1563 192.168.1.2 S0/2/0 1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.1.0/24 Direct 0 0 192.168.1.1 S0/2/0 192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.1.2/32 Direct 0 0 192.168.1.2 S0/2/0 六.OSPF中的NSSA区域 此实验的小目录 验证NSSA不学习其他区域引进的外部路由 [R4-ospf-1-area-0.0.0.2] nssa default-route-advertise NSSA的完全末节区域 [R4-ospf-1-area-0.0.0.2] nssa no-summary NSSA可以引入外部路由,7转为5类lsa 配置RIPv2 [R1] [R1]rip [R1-rip-1]ver 2 [R1-rip-1]un s [R1-rip-1]net 192.168.1.0 [R1-rip-1]net 1.1.1.0 [R1-rip-1]q 配置ospf [R2]rip [R2-rip-1]ver 2 [R2-rip-1]un s [R2-rip-1]net 192.168.1.0 [R2-rip-1]q [R2]ospf [R2-ospf-1]area 1 [R2-ospf-1-area-0.0.0.1]net 2.2.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.1]net 192.168.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.1]q [R2-ospf-1]q [R3]ospf [R3-ospf-1]area 1 [R3-ospf-1-area-0.0.0.1]net 192.168.2.0 0.0.0.255 [R3-ospf-1-area-0.0.0.1]q [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]net 3.3.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]q [R3-ospf-1]q [R4]ospf [R4-ospf-1]area 0 [R4-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R4]ospf [R4-ospf-1]area 2 [R4-ospf-1-area-0.0.0.2]net 192.168.4.0 0.0.0.255 [R4-ospf-1-area-0.0.0.2]q [R4-ospf-1]q [R5]ospf [R5-ospf-1]area 2 [R5-ospf-1-area-0.0.0.2]net 192.168.4.0 0.0.0.255 [R5-ospf-1-area-0.0.0.2]network 5.5.5.0 0.0.0.255 [R5-ospf-1-area-0.0.0.2]q 在没有配置 NSSA之前,区域2是可以学习到区域1引入的路由 [R5]display ospf routing OSPF Process 1 with Router ID 5.5.5.5 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.3.0/24 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2 192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2 5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2 3.3.3.3/32 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2 2.2.2.2/32 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2 192.168.2.0/24 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 1.1.1.1/32 1 Type2 1 192.168.4.1 2.2.2.2 Total Nets: 7 Intra Area: 2 Inter Area: 4 ASE: 1 NSSA: 0 并能ping通 [R5]ping 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Request time out Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=252 time=5 ms Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=252 time=5 ms Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=252 time=11 ms Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=252 time=25 ms 验证NSSA不学习其他区域引进的外部路由 首先验证使用RIP的原因就是验证NSSA区域不能接受其他的ASBR发送的5类型LSA 把ospf引入RIPv2,把RIPv2引入OSPF网络! 配置NSSA区域 配置完NSSA就学不到rip的路由了 [R5]display ospf routing OSPF Process 1 with Router ID 5.5.5.5 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 192.168.3.0/24 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2 192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2 5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2 3.3.3.3/32 3124 Inter 192.168.4.1 4.4.4.4 0.0.0.2 2.2.2.2/32 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2 192.168.2.0/24 4686 Inter 192.168.4.1 4.4.4.4 0.0.0.2 Total Nets: 6 Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0 验证结果: 以上的输出表明区域间的路由是可以进入到NSSA 区域的;但是在R1 的路由表中并没有 出现在R3 上把RIP 重分布进来的路由,因此说明LSA 类型为5 的外部路由不能在NSSA 区域中传播,ABR 也没有能力把类型5 的LSA 转成类型7 的LSA [R4-ospf-1-area-0.0.0.2] nssa default-route-advertise 怎样让NSSA学到其他区域引进的外部路由呢? 和上面的不一样。这个命令可以让nssa区域学习到区域1和0的路由,为rip单独使用了个默认路由 [R5]display ip routing-table protocol ospf Public Routing Table : OSPF Summary Count : 7 OSPF Routing table Status : < Active> Summary Count : 5 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/0 O_NSSA 150 1 192.168.4.1 S0/2/0 2.2.2.2/32 OSPF 10 4686 192.168.4.1 S0/2/0 3.3.3.3/32 OSPF 10 3124 192.168.4.1 S0/2/0 192.168.2.0/24 OSPF 10 4686 192.168.4.1 S0/2/0 192.168.3.0/24 OSPF 10 3124 192.168.4.1 S0/2/0 OSPF Routing table Status : < Inactive> Summary Count : 2 Destination/Mask Proto Pre Cost NextHop Interface 5.5.5.5/32 OSPF 10 0 5.5.5.5 Loop0 192.168.4.0/24 OSPF 10 1562 192.168.4.2 S0/2/0 上面的输出可以看出,NSSA可以学到其他区域的路由,其他区域引入的路由成了默认路由 并可以看出NSSA可以学到34类lsa,增加了带宽使用,我们怎么解决呢? NSSA的完全末节区域 配置NSSA的完全末节区域:所有的路由都通过默认路由出去 [R5]display ospf routing OSPF Process 1 with Router ID 5.5.5.5 Routing Tables Routing for Network Destination Cost Type NextHop AdvRouter Area 0.0.0.0/0 1563 Inter 192.168.4.1 4.4.4.4 0.0.0.2 192.168.4.0/24 1562 Stub 192.168.4.2 5.5.5.5 0.0.0.2 5.5.5.5/32 0 Stub 5.5.5.5 5.5.5.5 0.0.0.2 Total Nets: 3 Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0 [R5]display ip routing-table Routing Tables: Public Destinations : 7 Routes : 7 Destination/Mask Proto Pre Cost NextHop Interface 0.0.0.0/0 OSPF 10 1563 192.168.4.1 S0/2/0 5.5.5.5/32 Direct 0 0 127.0.0.1 InLoop0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.4.0/24 Direct 0 0 192.168.4.2 S0/2/0 192.168.4.1/32 Direct 0 0 192.168.4.1 S0/2/0 192.168.4.2/32 Direct 0 0 127.0.0.1 InLoop0 [R5]ping 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=252 time=10 ms Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=252 time=1 ms Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=252 time=5 ms 上面的输出说明,NSSA区域已经过滤掉了3类lsa NSSA可以引入外部路由,7转为5类lsa 配置静态路由并引入 在nssa区域中,类型是O_NSSA <R4>display ip routing-table Routing Tables: Public Destinations : 15 Routes : 15 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 O_ASE 150 1 192.168.3.1 S0/2/0 2.2.2.2/32 OSPF 10 3124 192.168.3.1 S0/2/0 3.3.3.3/32 OSPF 10 1562 192.168.3.1 S0/2/0 4.4.4.4/32 Direct 0 0 127.0.0.1 InLoop0 5.5.5.5/32 OSPF 10 1562 192.168.4.2 S0/2/3 10.10.10.0/24 O_NSSA 150 1 192.168.4.2 S0/2/3 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.2.0/24 OSPF 10 3124 192.168.3.1 S0/2/0 192.168.3.0/24 Direct 0 0 192.168.3.2 S0/2/0 192.168.3.1/32 Direct 0 0 192.168.3.1 S0/2/0 192.168.3.2/32 Direct 0 0 127.0.0.1 InLoop0 192.168.4.0/24 Direct 0 0 192.168.4.1 S0/2/3 192.168.4.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.4.2/32 Direct 0 0 192.168.4.2 S0/2/3 在其他区域中,类型是O_ASE [R3]display ip routing-table Routing Tables: Public Destinations : 14 Routes : 14 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 O_ASE 150 1 192.168.2.1 S0/2/0 2.2.2.2/32 OSPF 10 1562 192.168.2.1 S0/2/0 3.3.3.3/32 Direct 0 0 127.0.0.1 InLoop0 5.5.5.5/32 OSPF 10 3124 192.168.3.2 S0/2/2 10.10.10.0/24 O_ASE 150 1 192.168.3.2 S0/2/2 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.2.0/24 Direct 0 0 192.168.2.2 S0/2/0 192.168.2.1/32 Direct 0 0 192.168.2.1 S0/2/0 192.168.2.2/32 Direct 0 0 127.0.0.1 InLoop0 192.168.3.0/24 Direct 0 0 192.168.3.1 S0/2/2 192.168.3.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.3.2/32 Direct 0 0 192.168.3.2 S0/2/2 192.168.4.0/24 OSPF 10 3124 192.168.3.2 S0/2/2
|