为什么我会丢失 OSPF 路由?

网络工程 ospf 数据包追踪器
2021-07-16 10:58:49

我创建了小网络并设置了 OSPF 协议。当我拿走一根以太网电缆时,我希望看到路由表的变化......

但发生的情况是路由器只显示直接连接的网络,没有显示 OSPF。

请注意:它仍然有其他路由器连接到它。我移除的只是一根网线。在此处输入图片说明

当一切都连接起来时,这是 R0 路由表。

     192.168.1.0/29 is subnetted, 1 subnets
C       192.168.1.0 is directly connected, FastEthernet0/1
     192.168.2.0/29 is subnetted, 1 subnets
C       192.168.2.0 is directly connected, FastEthernet0/0
     192.168.3.0/29 is subnetted, 1 subnets
O       192.168.3.0 [110/2] via 192.168.1.2, 00:00:49, FastEthernet0/1
     192.168.4.0/29 is subnetted, 1 subnets
O       192.168.4.0 [110/2] via 192.168.2.2, 00:00:49, FastEthernet0/0

当我断开 R1 和 R0 时,这是 R0 路由表(所有 ospf 网络都消失了)

     192.168.1.0/29 is subnetted, 1 subnets
C       192.168.1.0 is directly connected, FastEthernet0/1

问题是为什么会这样。除了断开连接的那个之外,它不应该保持不变吗?

R0
Router(config)#router ospf 1
Router(config-router)#network 192.168.1.0 0.0.0.7 area 0
Router(config-router)#network 192.168.2.0 0.0.0.7 area 0

R1
Router(config)#router ospf 1
Router(config-router)#network 192.168.2.0 0.0.0.7 area 0
Router(config-router)#network 192.168.4.0 0.0.0.7 area 0

R2
Router(config)#router ospf 1
Router(config-router)#network 192.168.4.0 0.0.0.7 area 0
Router(config-router)#network 192.168.3.0 0.0.0.7 area 0

R3
Router(config)#router ospf 1
Router(config-router)#network 192.168.3.0 0.0.0.7 area 0
Router(config-router)#network 192.168.1.0 0.0.0.7 area 0

R0

Router#show run
Building configuration...

Current configuration : 692 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
ip cef
no ipv6 cef
!
spanning-tree mode pvst
!
interface FastEthernet0/0
 ip address 192.168.2.1 255.255.255.248
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.1.1 255.255.255.248
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 1
 log-adjacency-changes
 network 192.168.1.0 0.0.0.7 area 0
 network 192.168.2.0 0.0.0.7 area 0
!
ip classless
!
ip flow-export version 9

line con 0
!
line aux 0
!
line vty 0 4
 login
end

R1

Router#show run
Building configuration...

Current configuration : 692 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.2.2 255.255.255.248
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.4.1 255.255.255.248
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 1
 log-adjacency-changes
 network 192.168.2.0 0.0.0.7 area 0
 network 192.168.4.0 0.0.0.7 area 0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

R2

Router#sh run
Building configuration...

Current configuration : 692 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.3.2 255.255.255.248
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.4.2 255.255.255.248
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 1
 log-adjacency-changes
 network 192.168.4.0 0.0.0.7 area 0
 network 192.168.3.0 0.0.0.7 area 0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end

R3

Router#sh run
Building configuration...

Current configuration : 692 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Router
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/0
 ip address 192.168.3.1 255.255.255.248
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 192.168.1.2 255.255.255.248
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 1
 log-adjacency-changes
 network 192.168.3.0 0.0.0.7 area 0
 network 192.168.1.0 0.0.0.7 area 0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end
1个回答

您看到的问题是由于缺少稳定的路由器 ID 造成的。

OSPF 需要一个路由器 ID 来在路由更新中标识自己。如果不手动指定路由器 ID,路由器将使用最高的环回地址作为路由器 ID。由于您尚未创建环回接口,因此路由器选择最高接口地址作为路由器 ID。

当您拔下电缆时,该接口上的 IP 地址不再有效(因为该接口已关闭)。所以 OSPF 进程停止运行。这就是为什么您看不到任何 OSPF 路由的原因。

好的做法是手动创建路由器 ID:

router ospf 1
router-id 1.1.1.1

请注意,尽管路由器 ID 像 IP 地址一样以点分十进制书写,但它不是地址——它只是一个数字。选择您喜欢的任何唯一号码。

或者,您可以创建一个环回接口。路由器将使用此地址作为路由器 ID。因为它是一个虚拟接口,所以它永远不会关闭。

interface Loopback 0
ip address 1.1.1.1 255.255.255.255