180426—【网络路由技术】:OSPF 综合实验

4 篇文章 0 订阅
3 篇文章 0 订阅
按:

消失了一段时间。
中间信了班主任的邪去准备 CTF,说得好听,以赛带学。但是那种从原理到术语,从找工具到找文档找各种乱起八遭学着用工具半天只能搞个皮毛的东西。。还是算了吧。。
python 也暂时放下了。
社团的事情有很多要去忙。
机缘巧合,开始学习 CCIE 相关课程。
所以消失了不是放弃学习了。。

实验拓扑及需求:
这里写图片描述

1,按照如图所示配置好路由器的接口地址。在每台路由器上必须建立 loopback0 接口。
2,配置好 OSPF,区域划分如图所示,并且 ospf 的 router-id 必须为 loopback0 的地址。最终 实现全网互联。
3,在 R1、R2、R3、R4 之间的多路访问网络里面,必须是的 R1 成为 DR,R2 成为 BDR。在其余的链路里面必须保障 OSPF 邻居的快速建立,而不需要经过 wait timer。
4,在 R1 和 R2 上建立 loopback10,接口的地址为同样的 100.1.1.1/32 来模拟外网的接入。要求 R1 和 R2 都向内网通告一条缺省路由,正常的时候所有的路由器通过 R1 的缺省路由来访问外网,当 R1 无法正常工作的时候,通过 R2 来访问外网。(需要在 R7 上使用 traceroute 来测试路线。)
5,area2 为特殊区域,该区域无法学习到 ospf 其他区域的路由。R7 的 loopback0 的地址通过 redistributeconnected subnets 命令进入 ospf。(观察 R5 和 R6 上的 7.7.7.0 路由的来源,思考原因。)
6,在 R3 上创建 loopback1-3,地址为 172.16.x.1/24(x 为 1-3)。并且宣告进 OSPF 区域 1,要求在 area0 只能看到一条汇总的路由 172.16.0.0
7,area 0 需要启用明文区域认证,R3 和 R5 之间明文链路认证,R4 和 R6 之间密文链路认证。
8,禁止 area2 内的 192.168.57.0/24 和 192.168.67.0/24 被其他区域学习到。此刻思考区域 0 里面关于 7.7.7.0 的路由消失的原因,并且需要解决 7.7.7.0 消失的问题。

先解决第一步到第三步,配置 IP 地址及 ospf 进程:

R1
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.12.1 255.255.255.0
 ip ospf network point-to-point        \\改网络类型为点对点,为了满足题目3里面的跳过wait timer的需求。
 ip ospf 1 area 0
!
interface FastEthernet0/1
 ip address 192.168.234.1 255.255.255.0
 ip ospf priority 100                 \\改接口ospf的优先级,为了让R1成为DR
 ip ospf 1 area 0
!
interface FastEthernet1/0
 ip address 192.168.13.1 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
router ospf 1
 router-id 1.1.1.1        \\设置OSPF的route-id,防止被其他的接口抢走route-id
============================================================================

R2
interface Loopback0
 ip address 2.2.2.2 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.12.2 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
interface FastEthernet0/1
 ip address 192.168.234.2 255.255.255.0
 ip ospf priority 10        \\设置接口的优先级,让R2成为BDR
 ip ospf 1 area 0
!
interface FastEthernet1/0
 ip address 192.168.24.2 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
router ospf 1
 router-id 2.2.2.2
============================================================================

R3
interface Loopback0
 ip address 3.3.3.3 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.13.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
interface FastEthernet0/1
 ip address 192.168.234.3 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet1/0
 ip address 192.168.35.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 1
!
router ospf 1
 router-id 3.3.3.3
 area 1 virtual-link 5.5.5.5        \\虚链路
============================================================================
R4


interface Loopback0
 ip address 4.4.4.4 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
interface FastEthernet0/1
 ip address 192.168.234.4 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet1/0
 ip address 192.168.46.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 1
!
router ospf 1
 router-id 4.4.4.4
 area 1 virtual-link 6.6.6.6          \\虚链路.
============================================================================

R5
interface Loopback0
 ip address 5.5.5.5 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.35.5 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 1
!
interface FastEthernet0/1
 ip address 192.168.57.5 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 2
!
router ospf 1
 router-id 5.5.5.5
 area 1 virtual-link 3.3.3.3           \\虚链路别忘了
============================================================================

R6
interface Loopback0
 ip address 6.6.6.6 255.255.255.0
 ip ospf 1 area 0
!
interface FastEthernet0/0
 ip address 192.168.46.6 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 1
!
interface FastEthernet0/1
 ip address 192.168.67.6 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 2
!
router ospf 1
 router-id 6.6.6.6
 area 1 virtual-link 4.4.4.4                     \\虚链路
============================================================================

R7
interface Loopback0
 ip address 7.7.7.7 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.168.57.7 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 2
!
interface FastEthernet0/1
 ip address 192.168.67.7 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 2
!
router ospf 1
 router-id 7.7.7.7
============================================================================

一个好的习惯是当全网配置好 ospf 之后逐台路由器检查一下邻居关系和直连情况,以防止后续步骤出现灵异现象无从下手排错。
有几个点需要记住:

关于 ospf 中 DR&BDR 存在的问题

观察区域 0 中四台路由器的相连情况。拿 R1 和 R2 举例,它们有两条路直连,当把 12.0 网段配置为 P2P 网络类型时,有邻居关系为:
这里写图片描述

这说明:DR 与 BDR 的选举存在于任何直连的网络中,就算两台设备有两条路直连,也会在两条路上都选,就算你们在同一个区域中。因为 DR 制度基于端口。只不过当直连网络规模大一点时 DR 才会发挥其应有的作用。同时,这也解决了这样一个问题:
如果想修改优先级以保证 R1 成为 DR 应该去哪个接口?自然是 234.0 网段的接口。
当我们把 R1\2,R1\3,R2\4 之间的网络改为 P2P,只看剩下的星型拓扑 234.0,便得到一个纯粹的 DR&BDR 应该存在的地方。此中 R1 为 DR,R2 为 BDR,其余为 drother

另外,当仅配置一边的虚链路时无法下发缺省路由,暂时未解决。

================================================================
需求四
在 R1 和 R2 上建立 loopback10,接口的地址为同样的 100.1.1.1/32 来模拟外网的接入。要求 R1 和 R2 都向内网通告一条缺省路由,正常的时候所有的路由器通过 R1 的缺省路由来访问外网,当 R1 无法正常工作的时候,通过 R2 来访问外网。(需要在 R7 上使用 traceroute 来测试路线。)

这里只不过是随便拿了个网络(100.1.1.1)来模拟外网,至于 R1,2 上都有… 路由器总归都能上百度之类的吧?
常规操作…..

R1
interface Loopback10
 ip address 100.1.1.1 255.255.255.255
!
router ospf 1
 default-information originate always
 \\总是通告一条缺省路由,来让不知道外网的路由器找到这里
 ==============================================================
 R2
interface Loopback10
 ip address 100.1.1.1 255.255.255.255
!
router ospf 1
 default-information originate always metric 10
 \\增大了度量值,让内网不要优选R2走,除非R1坏了才从R2走。
总是通告默认路由

router ospf 1
default-information originate always
一开始还打算用路由汇总的办法用 ASBR 向内网通告。但是这样做无法满足下发缺省路由的要求。

default-information originate
这条命令用来产生一条五类的 LSA,包含的是缺省路由信息。
其它路由器收到这条 LSA 后,会计算出缺省路由 0.0.0.0/0。
命令生效的条件是该路由器上存在缺省路由。

如果没有,而且仍然想发布这种 LSA,要在命令后面加 always,即
default-information originate always
此时 ASBR 总会下发一条缺省路由。

另外,这条命令如果想 no 掉的话要 no 两个,第一次只能 no 掉参数(always)。

控制优先级

在汇总的命令后面直接加 metric 修改其度量值即可决定 R7 去往外网的优先路径。

===============================================================
题目 5 的需求是设置一个特殊区域,然后用 R7 的 lo0 接口来模拟外部的路由。
根据题目需求,应该是 nssa no-summary 区域,因为只有该区域不学习其他区域的路由,同时还允许外部路由的进入。
在 5、6、7 上分别配置 t-nssa 区域:

R5&R6&R7           \\三台路由器都需要这两条命令
router ospf 1
 area 2 nssa no-summary

R7
router ospf 1
 redistribute connected subnets
\\用这条命令来模拟lo0接口是外网进入OSPF。上面的步骤并没有将该接口宣告进OSPF。
  这条命令表示将R7直连接口及子网路由强行拉入ospf进程,但是并不属于其中。

此刻观察 R5 或者 R6 应该会发现一台路由器的路由表 7.7.7.0 是 O N2 的路由,一台是 O E2 的路由。因为 OSPF 如果从多种 LSA 类型学习到同一个路由条目会遵循以下优选规则:

OSPF 路由计算优选次序:
(1) 直连路由:本路由器发起的 LSA 1、2;

(2) 区域内路由:O; LSA 1、2;

(3) 区域间路由:O IA; LSA 3;

(4) 1 类外部路由:O E1; LSA 5 类型 1;

(5) 2 类外部路由:O E2: LSA 5 类型 2;

(6) 1 类 NSSA 路由:O N1; LSA 7 类型 1;

(7) 2 类 NSSA 路由:O N2; LSA 7 类型 2。

而如果 R6 先学习到了 7.7.7.0 通过 7 类的 LSA,就会以 O N2 的方式进入路由表,然后作为 ABR 的 R6 会将该 7 类的 LSA 转换成 5 类的 LSA 进入其他区域,而 R5 就会收到两种类型的 LSA 来描述 7.7.7.0, 会优选 5 类的。

=================================================================
题目 6 是在 R3 上创建三个 172.16.x.1/24 的路由进入区域 1,需要在区域 0 里面看到最后只有一条汇总的路由。

要注意,要想彻底的杜绝区域 0 出现明细,就需要在区域 1 和 0 的所有边界 ABR 做汇总,而本实验中,

R3
interface Loopback1
 ip address 172.16.1.1 255.255.255.0
 ip ospf 1 area 1
!
interface Loopback2
 ip address 172.16.2.1 255.255.255.0
 ip ospf 1 area 1
!
interface Loopback3
 ip address 172.16.3.1 255.255.255.0
 ip ospf 1 area 1
 ====================================================
R3&R5      \\这两台路由器都是区域10的边界ABR。都需要做汇总
router ospf 1
 area 1 range 172.16.0.0 255.255.0.0
ABR 通过三类 LSA 到底会通告那些链路?

在此处,R3,R4,R5,R6 都是区域 1 和 0 的边界 ABR,但是因为 35、46 之间并未互通,并且区域号在 LSA 中是不会携带的所以其实可以看做有两个区域 1,之间并未直连,因此,当我们在 R3 身上引入 172.16.0.0 网段时。R4 并不能通过 1 类或 2 类 LSA 从本区域学到。就更不会向区域 0 通告包含此条路由信息的三类 LSA 了。
卷一有云:

一台 ABR 路由器也可以通过网络汇总 LSA 向骨干区域通告与它相连的区域内部的目的地址

强调 与它相连

=======================================================
题目 7 就是命令而已,记得区域 0 里还有两台虚链路:

R1
router ospf 1
 area 0 authentication
============================================================================

R2
router ospf 1
 area 0 authentication
============================================================================

R3
router ospf 1
 area 0 authentication
interface FastEthernet1/0
 ip ospf authentication
 ip ospf authentication-key cisco
============================================================================

R4
router ospf 1
 area 0 authentication
interface FastEthernet1/0
 ip ospf authentication message-digest
 ip ospf message-digest-key 1 md5 cisco
============================================================================

R5
router ospf 1
 area 0 authentication
interface FastEthernet0/0
 ip ospf authentication
 ip ospf authentication-key cisco
============================================================================

R6
router ospf 1
 area 0 authentication
interface FastEthernet0/0
 ip ospf authentication message-digest
 ip ospf message-digest-key 1 md5 cisco

============================================================
在 R5 和 R6 上禁止 192.168.57.0/24 和 192.168.67.0/24 进入其他区域:


R5&R6        
\\两台路由器都要输入命令,并且是都要输两个网段,这次56通过7连在了一个区域里!
router ospf 1
 area 2 range 192.168.57.0 255.255.255.0 not-advertise
 area 2 range 192.168.67.0 255.255.255.0 not-advertise

会发现区域 0 里面的路由器除了 R5 和 R6 学习不到 7.7.7.0 了,通过查看 database 发现

R1#show ip ospf database external 
            OSPF Router with ID (1.1.1.1) (Process ID 1)
                Type-5 AS External Link States
  Routing Bit Set on this LSA
  LS age: 9
  Options: (No TOS-capability, DC)
  LS Type: AS External Link
  Link State ID: 7.7.7.0 (External Network Number )
  Advertising Router: 6.6.6.6
  LS Seq Number: 80000005
  Checksum: 0x2E41
  Length: 36
  Network Mask: /24
        Metric Type: 2 (Larger than any link state path)
        TOS: 0 
        Metric: 20 
        Forward Address: 192.168.67.7
        \\该转发地址不可达,导致这条lsa虽然存在database中,但是也不会使用
        External Route Tag: 0

通过在 R5 和 R6 上修改 7 类转换成 5 类 LSA 时候的 Fordward 地址,实现转发地址可达。

R5&R6
router ospf 1
area 2 nssa translate type7 suppress-fa
该条命令使得 ABR 将 7 类 LSA 转变为 5 类时将 forward address 替换为自己。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值