OSPF配置

 拓扑图

基本配置:

R1:

Router>enable
Router#configure terminal
Router(config)#hostname R1
R1(config)#no ip domain-lookup
R1(config)#line console 0
R1(config-line)#exec-timeout 0 0
R1(config-line)#logging synchronous

 

R2:

Router>enable
Router#configure terminal
Router(config)#hostname R2
R2(config)#no ip domain-lookup
R2(config)#line console 0
R2(config-line)#exec-timeout 0 0
R2(config-line)#logging synchronous

 

 

 

配置IP及OSPF:

R1:
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface s1/1
R1(config-if)#ip address 172.16.2.1 255.255.255.0
R1(config-if)#no shutdown

R1(config)#router ospf 1   
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.2.0 0.0.0.255 area 0

 

R2:

R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface s1/0
R2(config-if)#ip address 172.16.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#router ospf 2
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R2(config-router)#network 172.16.2.0 0.0.0.255 area 0

 

验证:

R1#show 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, su - IS-IS summary, 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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 172.16.2.2, 00:00:48, Serial1/1
     172.16.0.0/24 is subnetted, 1 subnets

C       172.16.2.0 is directly connected, Serial1/1

R1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 48/81/120 ms

R1#show ip ospf database

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

                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
1.1.1.1         1.1.1.1         135         0x80000003 0x000BF3 3
2.2.2.2         2.2.2.2         135         0x80000003 0x002DC8 3

 

 

以下为DR与BDR实验:

知识点:DR与BDR只有在广播和非广播的多路访问上选举,点到点链路,例如串行WAN连接,将不会进行DR的选举.(但这里广播类型点到点连接却证明是可以选举的,因为考虑OSPF邻居建立条件,HELLO间隔一致否,区域ID一致否,验证和STUB标示一致否,那这里只考虑HELLO间隔和区域ID)

R1:

R1(config)#interface s1/1
R1(config-if)#ip ospf network broadcast

R1#show ip ospf interface s1/1
Serial1/1 is up, line protocol is up
  Internet Address 172.16.2.1/24, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 64
  Transmit Delay is 1 sec, State DROTHER, Priority 1
  Designated Router (ID) 2.2.2.2, Interface address 172.16.2.2
  Backup Designated router (ID) 2.2.2.2, Interface address 172.16.2.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:02
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2  (Designated Router)
  Suppress hello for 0 neighbor(s)

R2:

R2#show ip ospf interface s1/0
Serial1/0 is up, line protocol is up
  Internet Address 172.16.2.2/24, Area 0
  Process ID 2, Router ID 2.2.2.2, Network Type POINT_TO_POINT, Cost: 64
  Transmit Delay is 1 sec, State POINT_TO_POINT,
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:00
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 1.1.1.1
  Suppress hello for 0 neighbor(s)

R2#conf t

R2(config)#interface s1/0
R2(config-if)#ip ospf network broadcast

 

验证是否选举了DR和BDR:

R1:

R1#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:00:37    172.16.2.2      Serial1/1

 

R2:

R2#show ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:37    172.16.2.1      Serial1/0

 

R1:

R1#show ip ospf interface s1/1
Serial1/1 is up, line protocol is up
  Internet Address 172.16.2.1/24, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 64
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 1.1.1.1, Interface address 172.16.2.1
  Backup Designated router (ID) 2.2.2.2, Interface address 172.16.2.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:04
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)

 

注意:这里R2的RID(任何逻辑接口的IP会成为路由器的RID)应该比R1的RID大,但R1在第一次修改网络类型的时候,已经把自己选举为DR,而整个选举过程是从其的,就是除非R1坏掉或者其他原因不能通信,才会重新选举,那么R2才会成为DR.

人工选举DR

R1:

R1#conf t    
R1(config)#interface s1/1
R1(config-if)#ip os priority 0

 

R2:

R2(config)#int s1/0
R2(config-if)#ip ospf priority 255

 

验证:

R1:

R1#show ip ospf int s1/1
Serial1/1 is up, line protocol is up
  Internet Address 172.16.2.1/24, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 64
  Transmit Delay is 1 sec, State DROTHER, Priority 0
  Designated Router (ID) 2.2.2.2, Interface address 172.16.2.2
  No backup designated router on this network
  Old designated Router (ID) 1.1.1.1, Interface address 172.16.2.1
  Flush timer for old DR LSA due in 00:01:09
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:08
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2  (Designated Router)
  Suppress hello for 0 neighbor(s)

 

R2:

R2#show ip ospf int s1/0
Serial1/0 is up, line protocol is up
  Internet Address 172.16.2.2/24, Area 0
  Process ID 2, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 64
  Transmit Delay is 1 sec, State DR, Priority 255
  Designated Router (ID) 2.2.2.2, Interface address 172.16.2.2
  No backup designated router on this network
  Old designated Router (ID) 1.1.1.1, Interface address 172.16.2.1
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:07
  Index 2/2, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 2, maximum is 2
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 1.1.1.1
  Suppress hello for 0 neighbor(s)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值