广播网络中的运行ospf协议,我们都知道在MA网络中是支持广播、组播、多播的网络;而且在OSPF也因为有了广播而很快的发现邻居,在OSPF网络当中DR与BDR之间传送数据是使用224.0.0.6网段的广播地址,可想而知DR在与DROTHER通讯就是使用244.0.0.5网段的广播地址!
我们下面是来介绍一下OSPF在广播网络中的使用,当然交换机连接最为典型了,交换机就延长网络,通过广播的;那我们来搭建一下这个环境。在这个网络中只有一对DR与BDR。(DR与BDR是以网段为基础的)
 

广播网络中运行的ospf路由协议_职场


首先我们先来配置一下路由器R1:
Router#config ter
Router(config)#hostname R1
R1(config)#inter  fa0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
这一步我们是把R1的接口的IP地址配置好了,下面我们如法炮制把路由R2、R3、R4都配置好接口的IP地址。
R2:
Router#config ter
Router(config)#hostname R2
R2(config)#inter  fa0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R3:
Router#config ter
Router(config)#hostname R3
R3(config)#inter  fa0/0
R3(config-if)#ip add 192.168.12.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R4:
Router#config ter
Router(config)#hostname R4
R4(config)#inter  fa0/0
R4(config-if)#ip add 192.168.12.4 255.255.255.0
R4(config-if)#no shut
R4(config-if)#exit
现在我们就把所有的路由接口的IP 地址配置好了!
R1(config)#router ospf 1
R1(config-router)#network 192.168.12.0 0.0.0.255 a 0
R1(config-router)#exit
R1(config)#exit
到了这一步,我们是把OSPF路由协议开启,会通过广播发布出去只要是由运行OSPF协议的路由就会接收来自R1的Hello包;下面我们也是如法炮制把R2、R3、R4都开启OSPF。
R2:
R2(config)#router ospf 1
R2(config-router)#network 192.168.12.0 0.0.0.255 a 0
R2(config-router)#exit
R2(config)#exit
R3:
R3(config)#router ospf 1
R3(config-router)#network 192.168.12.0 0.0.0.255 a 0
R3(config-router)#exit
R3(config)#exit
R4:
R4(config)#router ospf 1
R4(config-router)#network 192.168.12.0 0.0.0.255 a 0
R4(config-router)#exit
R4(config)#exit
现在我们就搭建的差不多了,OSPF也都发布完了。
我们可以通过以下命令来查看一下R1、R2、R3、R4上有关OSPF的信息
R1:
R1#show  ip  ospf                                     
 Routing Process "ospf 1" with ID 192.168.12.1
 Start time: 06:30:10.456, Time elapsed: 00:17:01.508
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 Supports Link-local Signaling (LLS)
 Supports area transit capability
 Router is not originating router-LSAs with maximum metric
 Initial SPF schedule delay 5000 msecs
 Minimum hold time between two consecutive SPFs 10000 msecs
 Maximum wait time between two consecutive SPFs 10000 msecs
 Incremental-SPF disabled
 Minimum LSA interval 5 secs
 Minimum LSA arrival 1000 msecs
 LSA group pacing timer 240 secs
 Interface flood pacing timer 33 msecs
 Retransmission pacing timer 66 msecs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Number of areas transit capable is 0
 External flood list length 0
    Area BACKBONE(0)
        Number of interfaces in this area is 1
        Area has no authentication
        SPF algorithm last executed 00:09:26.052 ago
        SPF algorithm executed 5 times
        Area ranges are
        Number of LSA 5. Checksum Sum 0x03BFB8
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0
R2:
R2#show  ip  ospf
 Routing Process "ospf 1" with ID 192.168.12.2
 Start time: 06:30:41.888, Time elapsed: 00:17:44.336
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 Supports Link-local Signaling (LLS)
 Supports area transit capability
 Router is not originating router-LSAs with maximum metric
 Initial SPF schedule delay 5000 msecs
 Minimum hold time between two consecutive SPFs 10000 msecs
 Maximum wait time between two consecutive SPFs 10000 msecs
 Incremental-SPF disabled
 Minimum LSA interval 5 secs
 Minimum LSA arrival 1000 msecs
 LSA group pacing timer 240 secs
 Interface flood pacing timer 33 msecs
 Retransmission pacing timer 66 msecs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Number of areas transit capable is 0
 External flood list length 0
    Area BACKBONE(0)
        Number of interfaces in this area is 1
        Area has no authentication
        SPF algorithm last executed 00:10:20.616 ago
        SPF algorithm executed 4 times
        Area ranges are
        Number of LSA 5. Checksum Sum 0x03BFB8
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0
R3:
R3#show  ip ospf
 Routing Process "ospf 1" with ID 192.168.12.3
 Start time: 06:37:27.876, Time elapsed: 00:12:19.504
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 Supports Link-local Signaling (LLS)
 Supports area transit capability
 Router is not originating router-LSAs with maximum metric
 Initial SPF schedule delay 5000 msecs
 Minimum hold time between two consecutive SPFs 10000 msecs
 Maximum wait time between two consecutive SPFs 10000 msecs
 Incremental-SPF disabled
 Minimum LSA interval 5 secs
 Minimum LSA arrival 1000 msecs
 LSA group pacing timer 240 secs
 Interface flood pacing timer 33 msecs
 Retransmission pacing timer 66 msecs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Number of areas transit capable is 0
 External flood list length 0
    Area BACKBONE(0)
        Number of interfaces in this area is 1
        Area has no authentication
        SPF algorithm last executed 00:11:46.588 ago
        SPF algorithm executed 2 times
        Area ranges are
        Number of LSA 5. Checksum Sum 0x03BFB8
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0
R4:
R4#show  ip  ospf
 Routing Process "ospf 1" with ID 192.168.12.4
 Start time: 05:54:25.064, Time elapsed: 00:55:58.224
 Supports only single TOS(TOS0) routes
 Supports opaque LSA
 Supports Link-local Signaling (LLS)
 Supports area transit capability
 Router is not originating router-LSAs with maximum metric
 Initial SPF schedule delay 5000 msecs
 Minimum hold time between two consecutive SPFs 10000 msecs
 Maximum wait time between two consecutive SPFs 10000 msecs
 Incremental-SPF disabled
 Minimum LSA interval 5 secs
 Minimum LSA arrival 1000 msecs
 LSA group pacing timer 240 secs
 Interface flood pacing timer 33 msecs
 Retransmission pacing timer 66 msecs
 Number of external LSA 0. Checksum Sum 0x000000
 Number of opaque AS LSA 0. Checksum Sum 0x000000
 Number of DCbitless external and opaque AS LSA 0
 Number of DoNotAge external and opaque AS LSA 0
 Number of areas in this router is 1. 1 normal 0 stub 0 nssa
 Number of areas transit capable is 0
 External flood list length 0
    Area BACKBONE(0)
        Number of interfaces in this area is 1
        Area has no authentication
        SPF algorithm last executed 00:12:22.856 ago
        SPF algorithm executed 11 times
        Area ranges are
        Number of LSA 5. Checksum Sum 0x03BFB8
        Number of opaque link LSA 0. Checksum Sum 0x000000
        Number of DCbitless LSA 0
        Number of indication LSA 0
        Number of DoNotAge LSA 0
        Flood list length 0
这样所有路由器的有关OSPF的信息我们一览无余了!

接下来我们在里说一下:“定义DR和BDR”
首先是比较的是优先级高者优先,当然这时要是同一优先级的;那就要来比较Router ID了也是大者优先,Router ID是不会相同的了,所以说在这里就会定义出来谁当DR。那么BDR大家也知道了吧,就是第二高的!(当然也不是绝对在这里我们有一句话那就是:稳定性压倒一切。什么意思呢?那就是要是DR已经选定出来,即使再来了优先级高的路由器(Rn)那也不会改变了,直到DR坏掉了也不会使用这个后来优先级高的Rn,因为还有BDR能使用,在这里作比较BDR是比Rn稳定性要高的;那么现在BDR成为了DR,Rn也就当上备份指定路由器BDR。所以说是稳定性压倒一切!)
我们可以通过下命令来看看R1、R2、R3、R4的Router ID和Priority(优先级)
R1:
R1#show ip ospf inter
FastEthernet0/0 is up, line protocol is up
  Internet Address 192.168.12.1/24, Area 0
  Process ID 1, Router ID 192.168.12.1, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DROTHER, Priority 1
  Designated Router (ID) 192.168.12.4, Interface address 192.168.12.4
  Backup Designated router (ID) 192.168.12.3, Interface address 192.168.12.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:02
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 192.168.12.3  (Backup Designated Router)
    Adjacent with neighbor 192.168.12.4  (Designated Router)
  Suppress hello for 0 neighbor(s)
R2:
R2#show ip ospf inter
FastEthernet0/0 is up, line protocol is up
  Internet Address 192.168.12.2/24, Area 0
  Process ID 1, Router ID 192.168.12.2, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DROTHER, Priority 1
  Designated Router (ID) 192.168.12.4, Interface address 192.168.12.4
  Backup Designated router (ID) 192.168.12.3, Interface address 192.168.12.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:01
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 4 msec
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 192.168.12.3  (Backup Designated Router)
    Adjacent with neighbor 192.168.12.4  (Designated Router)
  Suppress hello for 0 neighbor(s)
R3:
R3#show ip ospf inter
FastEthernet0/0 is up, line protocol is up
  Internet Address 192.168.12.3/24, Area 0
  Process ID 1, Router ID 192.168.12.3, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State BDR, Priority 1
  Designated Router (ID) 192.168.12.4, Interface address 192.168.12.4
  Backup Designated router (ID) 192.168.12.3, Interface address 192.168.12.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:05
  Supports Link-local Signaling (LLS)
  Index 1/1, 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 3, Adjacent neighbor count is 3
    Adjacent with neighbor 192.168.12.1
    Adjacent with neighbor 192.168.12.2
    Adjacent with neighbor 192.168.12.4  (Designated Router)
  Suppress hello for 0 neighbor(s)
R4:
R4#show ip ospf inter
FastEthernet0/0 is up, line protocol is up
  Internet Address 192.168.12.4/24, Area 0
  Process ID 1, Router ID 192.168.12.4, Network Type BROADCAST, Cost: 10
  Transmit Delay is 1 sec, State DR, Priority 1
  Designated Router (ID) 192.168.12.4, Interface address 192.168.12.4
  Backup Designated router (ID) 192.168.12.3, Interface address 192.168.12.3
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:06
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 4 msec
  Neighbor Count is 3, Adjacent neighbor count is 3
    Adjacent with neighbor 192.168.12.1
    Adjacent with neighbor 192.168.12.2
    Adjacent with neighbor 192.168.12.3  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
现在我相信都知道在这个拓扑当中谁是DR与BDR了,那我们就来看一下邻居表,下面命令是显示路由中的邻居表信息!(在OSPF中一定有三个表:邻居表、链路状态数据库表、路由表)
R1:
R1#show ip ospf neighbor邻居表
Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.12.2      1   2WAY/DROTHER    00:00:35    192.168.12.2    FastEthernet0/0
192.168.12.3      1   FULL/BDR        00:00:39    192.168.12.3    FastEthernet0/0
192.168.12.4      1   FULL/DR         00:00:35    192.168.12.4    FastEthernet0/0
R1#show  ip ospf database链路状态数据库表
            OSPF Router with ID (192.168.12.1) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.12.1    192.168.12.1    871         0x80000002 0x00DF6C 1
192.168.12.2    192.168.12.2    873         0x80000002 0x00DD6B 1
192.168.12.3    192.168.12.3    883         0x80000001 0x00DD69 1
192.168.12.4    192.168.12.4    872         0x80000006 0x00D16D 1
                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.4    192.168.12.4    872         0x80000001 0x00540B
R1#show ip route路由表
Codes: C - connected, S - static, 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
       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
C    192.168.12.0/24 is directly connected, FastEthernet0/0
R2:
R2#show ip ospf neighbor 邻居表
Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.12.1      1   2WAY/DROTHER    00:00:37    192.168.12.1    FastEthernet0/0
192.168.12.3      1   FULL/BDR        00:00:31    192.168.12.3    FastEthernet0/0
192.168.12.4      1   FULL/DR         00:00:37    192.168.12.4    FastEthernet0/0
R2#show ip ospf database 链路状态数据库表
            OSPF Router with ID (192.168.12.2) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.12.1    192.168.12.1    936         0x80000002 0x00DF6C 1
192.168.12.2    192.168.12.2    934         0x80000002 0x00DD6B 1
192.168.12.3    192.168.12.3    946         0x80000001 0x00DD69 1
192.168.12.4    192.168.12.4    935         0x80000006 0x00D16D 1
                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.4    192.168.12.4    935         0x80000001 0x00540B
R2#show ip route 路由表
Codes: C - connected, S - static, 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
       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
C    192.168.12.0/24 is directly connected, FastEthernet0/0
R3:
R3#show ip ospf neighbor 邻居表
Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.12.1      1   FULL/DROTHER    00:00:37    192.168.12.1    FastEthernet0/0
192.168.12.2      1   FULL/DROTHER    00:00:37    192.168.12.2    FastEthernet0/0
192.168.12.4      1   FULL/DR         00:00:37    192.168.12.4    FastEthernet0/0
R3#show ip ospf database 链路状态数据库表
            OSPF Router with ID (192.168.12.3) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.12.1    192.168.12.1    981         0x80000002 0x00DF6C 1
192.168.12.2    192.168.12.2    981         0x80000002 0x00DD6B 1
192.168.12.3    192.168.12.3    990         0x80000001 0x00DD69 1
192.168.12.4    192.168.12.4    980         0x80000006 0x00D16D 1
                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.4    192.168.12.4    980         0x80000001 0x00540B
R3#show ip route路由表
Codes: C - connected, S - static, 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
       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
C    192.168.12.0/24 is directly connected, FastEthernet0/0
R4:
R4#show ip ospf neighbor 邻居表
Neighbor ID     Pri   State           Dead Time   Address         Interface
192.168.12.1      1   FULL/DROTHER    00:00:33    192.168.12.1    FastEthernet0/0
192.168.12.2      1   FULL/DROTHER    00:00:33    192.168.12.2    FastEthernet0/0
192.168.12.3      1   FULL/BDR        00:00:37    192.168.12.3    FastEthernet0/0
R4#show ip ospf database 链路状态数据库表
            OSPF Router with ID (192.168.12.4) (Process ID 1)
                Router Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum Link count
192.168.12.1    192.168.12.1    1034        0x80000002 0x00DF6C 1
192.168.12.2    192.168.12.2    1033        0x80000002 0x00DD6B 1
192.168.12.3    192.168.12.3    1045        0x80000001 0x00DD69 1
192.168.12.4    192.168.12.4    1033        0x80000006 0x00D16D 1
                Net Link States (Area 0)
Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.4    192.168.12.4    1033        0x80000001 0x00540B
R4#show ip route 路由表
Codes: C - connected, S - static, 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
       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
C    192.168.12.0/24 is directly connected, FastEthernet0/0