Jeff DoyleTCP/IP路由技术 卷一上看到若网络掩码不匹配,则无法建立邻接关系,所以做个实验验证下,没想到发现了问题。设计拓扑图如下:

R—R2之间链路为192.168.12.0/24

以太网链路为192.168.1.0/24

 

正确配置IP地址和掩码,并配置OSPF协议。更改R3R4的接口优先级为0,使得R2成为DR。网络正常运行,正常建立邻接关系,查看如下:

R2#sh ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

3.3.3.3           0   FULL/DROTHER    00:00:37    192.168.1.3     FastEthernet1/0

4.4.4.4           0   FULL/DROTHER    00:00:34    192.168.1.4     FastEthernet1/0

1.1.1.1           0   FULL/  -         00:00:37    192.168.12.1    Serial0/0

 

现更改R1s0/0接口ip地址为192.168.12.1/16。查看其是否能建立邻居

R1#sh ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2.2           0   FULL/  -        00:00:34    192.168.12.2    Serial0/0

发现依旧可以建立邻居,这是点到点的链路,再尝试以太网链路。更改R3fa0/0接口ip地址为192.168.1.3/16,发现R3没有了OSPF邻居。而R2依旧和其他路由器保持着full状态,如下:

R2#sh ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

4.4.4.4           0   FULL/DROTHER    00:00:34    192.168.1.4     FastEthernet1/0

1.1.1.1           0   FULL/  -        00:00:36    192.168.12.1    Serial0/0

R3  使用debug ip ospf event,结果如下:

R3#debug ip ospf ev

OSPF events debugging is on

R3#

*Mar  1 00:23:10.055: OSPF: Rcv hello from 2.2.2.2 area 0 from FastEthernet0/0 192.168.1.2

*Mar  1 00:23:10.055: OSPF: Mismatched hello parameters from 192.168.1.2

*Mar  1 00:23:10.059: OSPF: Dead R 40 C 40, Hello R 10 C 10  Mask R 255.255.255.0 C 255.255.0.0

显示hello参数不匹配,查看显示是掩码不匹配,当更改掩码后邻接关系恢复full状态。

 

难道点到点链路真可以正常的建立邻接关系吗?检查R1R2的路由表,如下:

R1#sh ip route

Gateway of last resort is not set

 

O    192.168.12.0/24 [110/128] via 192.168.12.2, 00:08:23, Serial0/0

     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 192.168.12.2, 00:08:23, Serial0/0

     4.0.0.0/32 is subnetted, 1 subnets

O       4.4.4.4 [110/66] via 192.168.12.2, 00:08:23, Serial0/0

O    192.168.1.0/24 [110/65] via 192.168.12.2, 00:08:23, Serial0/0

C    192.168.0.0/16 is directly connected, Serial0/0

 

 

R2#sh ip route

Gateway of last resort is not set

 

C    192.168.12.0/24 is directly connected, Serial0/0

     1.0.0.0/32 is subnetted, 1 subnets

O       1.1.1.1 [110/65] via 192.168.12.1, 00:08:44, Serial0/0

     2.0.0.0/24 is subnetted, 1 subnets

C       2.2.2.0 is directly connected, Loopback0

     4.0.0.0/32 is subnetted, 1 subnets

O       4.4.4.4 [110/2] via 192.168.1.4, 00:08:44, FastEthernet1/0

   192.168.1.0/24 is directly connected, FastEthernet1/0

O    192.168.0.0/16 [110/128] via 192.168.12.1, 00:08:44, Serial0/0

仔细观察路由表发现R1R2的路由表中均出现了ospf域内路由,并且其metric值均为128。究其原因是因为对端传来的1LSA,如下:

R2#sh ip ospf da router 1.1.1.1

 

            OSPF Router with ID (2.2.2.2) (Process ID 10)

 

                Router Link States (Area 0)

 

  LS age: 1096

  Options: (No TOS-capability, DC)

  LS Type: Router Links

  Link State ID: 1.1.1.1

  Advertising Router: 1.1.1.1

  LS Seq Number: 80000004

  Checksum: 0xCECD

  Length: 60

  Number of Links: 3

 

    Link connected to: another Router (point-to-point)

     (Link ID) Neighboring Router ID: 2.2.2.2

     (Link Data) Router Interface address: 192.168.12.1

      Number of TOS metrics: 0

       TOS 0 Metrics: 64

 

    Link connected to: a Stub Network

     (Link ID) Network/subnet number: 192.168.0.0

     (Link Data) Network Mask: 255.255.0.0

      Number of TOS metrics: 0

       TOS 0 Metrics: 64

 

    Link connected to: a Stub Network

     (Link ID) Network/subnet number: 1.1.1.1

     (Link Data) Network Mask: 255.255.255.255

      Number of TOS metrics: 0

       TOS 0 Metrics: 1

R2从接口S0/0收到R1传过来的LSA后,查看到一个stub network 192.168.0.0,其metric64,再加上自身接口s0/0metric 64,则到达192.168.0.0metric128。这样的路由表会导致数据的非正常转发。

 

当在多路访问网络时,需要选举DRBDR,选举的DR将生成2LSA2LSA数据包格式如下图:

 

 

其中以太网链路需要有统一的掩码,才有DR宣告出去