实验七 配置OSPF协议

要求:

    配置OSPF协议,实现全网互通,并在合适的路由器上修改OSPF开销,实现等值路径负载均衡。

基础配置

    为路由器R1、R2和R3设置相应的IP地址。

配置OSPF协议

1. 基本配置

r1(config)#router ospf 1

r1(config-router)#router-id 1.1.1.1

r1(config-router)#net 172.16.1.0 0.0.0.255 area 1

r1(config-router)#net 12.0.0.0 0.255.255.255 area 1

r1(config-router)#net 14.0.0.1 0.0.0.0 area 1

r2(config)#router ospf 1

r2(config-router)#router-id 2.2.2.2

r2(config-router)#net 12.0.0.2 0.0.0.0 area 1

r2(config-router)#net 23.0.0.2 0.0.0.0 area 1

r3(config)#router ospf 1

r3(config-router)#router-id 3.3.3.3

r3(config-router)#net 172.16.8.0 0.0.0.255 area 1

r3(config-router)#net 23.0.0.3 0.0.0.0 area 1

r3(config-router)#net 34.0.0.3 0.0.0.0 area 1

r4(config)#router ospf 1

r4(config-router)#router-id 4.4.4.4

r4(config-router)#net 14.0.0.4 0.0.0.0 area 1

r4(config-router)#net 34.0.0.4 0.0.0.0 area 1

2. 查看OSPF的邻居表、DR选举。

r1#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface

4.4.4.4           1   FULL/BDR        00:00:39    14.0.0.4        FastEthernet0/0

2.2.2.2           0   FULL/  -        00:00:30    12.0.0.2        Serial1/0

r1#sh ip ospf interface f0/0

FastEthernet0/0 is up, line protocol is up

  Internet address is 14.0.0.1/8, Area 1

  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1

  Transmit Delay is 1 sec, State DR, Priority 1

  Designated Router (ID) 1.1.1.1, Interface address 14.0.0.1

  Backup Designated Router (ID) 4.4.4.4, Interface address 14.0.0.4

  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5

因为,R1首先启动,40秒后成为了DR。虽然R4的ID号更大,但不能抢占DR。如果R4想成为DR,需要将两个路由器的接口shut, 然后no shut,重新选举。

若R1在新的选举中还想成为DR,则需要修改f0/0的接口优先级:

   R1(config )#int  f0/0

             #ip  ospf  priority  2

另外,DR选举,发生广播型多路访问网络(以太网)中,点到点链路上不需要选举DR。

3. 查看OSPF的LSDB表和路由表。

r1#sh ip ospf database

            OSPF Router with ID (1.1.1.1) (Process ID 1)

                Router Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum Link count

1.1.1.1         1.1.1.1         125         0x80000005 0x008973 4

2.2.2.2         2.2.2.2         210         0x80000004 0x001a61 4

3.3.3.3         3.3.3.3         125         0x80000005 0x0083e2 5

4.4.4.4         4.4.4.4         125         0x80000004 0x00d1ac 3

                Net Link States (Area 1)

Link ID         ADV Router      Age         Seq#       Checksum

14.0.0.1        1.1.1.1         125         0x80000001 0x00ac68

r1#sh ip route

Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP

       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

       * - candidate default, U - per-user static route, o - ODR

       P - periodic downloaded static route

Gateway of last resort is not set

C    12.0.0.0/8 is directly connected, Serial1/0

C    14.0.0.0/8 is directly connected, FastEthernet0/0

O    23.0.0.0/8 [110/1562] via 12.0.0.2, 00:05:23, Serial1/0

O    34.0.0.0/8 [110/782] via 14.0.0.4, 00:02:14, FastEthernet0/0

     172.16.0.0/24 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, FastEthernet0/1

O       172.16.8.0 [110/783] via 14.0.0.4, 00:02:14, FastEthernet0/0

可以看到,从R1到172.16.8.0有两条路可走:

      R1—R2—R3   781+781+1=1563

R1—R4—R3   1+781+1=783

OSPF选择了路径最短的: R1—R4—R3

4. 故障路径切换

当R4—R3之间的路径出现故障,OSPF会自动更新LSDB表,然后R1会自动重新计算前往172.16.8.0的路径:

   R1—R1—R3   781+781+1=1563

r1>sh ip route

O       172.16.8.0 [110/1563] via 12.0.0.2, 00:00:02, Serial1/0

5. 修改接口开销实现等值路径负载均衡。

r1(config)#int f0/0

r1(config-if)#ip ospf cost 781

r1#sh ip ospf int f0/0

FastEthernet0/0 is up, line protocol is up

  Internet address is 14.0.0.1/8, Area 1

  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 781

  Transmit Delay is 1 sec, State DR, Priority 1

r1#sh ip route

C    12.0.0.0/8 is directly connected, Serial1/0

C    14.0.0.0/8 is directly connected, FastEthernet0/0

O    23.0.0.0/8 [110/1562] via 12.0.0.2, 00:27:30, Serial1/0

O    34.0.0.0/8 [110/1562] via 14.0.0.4, 00:00:46, FastEthernet0/0

     172.16.0.0/24 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, FastEthernet0/1

O       172.16.8.0 [110/1563] via 12.0.0.2, 00:00:46, Serial1/0

                   [110/1563] via 14.0.0.4, 00:00:46, FastEthernet0/0

说明:OSPF的开销计算是按前往目标出方向的累加开销。由于数据通信是双向的,要实现返回数据的负载均衡,则还需要修改R4的f0/0的开销为781.

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

追逐太阳的星星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值