如何与 OSPF 一起实现默认路由?

网络工程 思科 路由 路由器 ospf
2022-02-21 23:40:56

我读了一些cisco的东西。它说OSPF和默认路由,默认网关,不是好朋友......

请参阅下面的架构:

简单的架构

现在在那个图中,我希望 PC1 能够到达 PC2 ......

为了到达任何黑色区域,我告诉 R1 通过 C 离开。

如何在没有大量静态路由的情况下使 A 和 F 通信?即我不想在中间浪费OSFP 路由。

我现在做的是例如:

  • 要到达C,R3必须离开R2的黑色接口连接。

如果我希望 PC1 (A) 和 PC 2 (F) 进行通信,我是否必须使用静态路由?这意味着我必须静态配置所有中间路由......因此,除了中间路由器之外,OSPF 毫无用处

更新

在与下面的答案交谈后Ron Maupin,我们决定更新问题。请点击下面的链接查看完整的(真实的)网络图:

在此处输入图像描述

这是配置:

R1

hostname R1
!
no ip cef
no ipv6 cef
!
license udi pid CISCO1941/K9 sn FTX15242RKT
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0/0
 ip address 192.168.14.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
 clock rate 2000000
!
interface Serial0/0/1
 ip address 192.168.15.2 255.255.255.248
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
 clock rate 2000000
!
interface Serial0/1/0
 ip address 192.168.1.129 255.255.255.192
 clock rate 2000000
!
interface Serial0/1/1
 ip address 192.168.12.2 255.255.255.248
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
 clock rate 2000000
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 100
 log-adjacency-changes
 area 100 authentication message-digest
 redistribute static subnets 
 network 192.168.12.0 0.0.0.7 area 100
 network 192.168.15.0 0.0.0.7 area 100
 network 192.168.14.0 0.0.0.255 area 100
 network 192.168.1.128 0.0.0.63 area 100
!
ip classless
ip route 10.10.10.0 255.255.255.0 192.168.1.130 
ip route 10.100.100.0 255.255.255.0 192.168.1.130 
!
ip flow-export version 9
!
!
!
no cdp run
!

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

R2

hostname R2
!
!
no ip cef
no ipv6 cef
!
license udi pid CISCO1941/K9 sn FTX1524PDUV
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0/0
 ip address 192.168.2.129 255.255.255.192
 clock rate 2000000
!
interface Serial0/0/1
 no ip address
 clock rate 2000000
 shutdown
!
interface Serial0/1/0
 ip address 192.168.12.1 255.255.255.248
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
!
interface Serial0/1/1
 ip address 192.168.23.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
 clock rate 2000000
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 100
 log-adjacency-changes
 area 100 authentication message-digest
 redistribute static subnets 
 network 192.168.23.0 0.0.0.255 area 100
 network 192.168.12.0 0.0.0.7 area 100
 network 192.168.2.128 0.0.0.63 area 100
!
router rip
!
ip classless
ip route 172.23.1.0 255.255.255.0 192.168.2.130 
!
ip flow-export version 9
!
no cdp run

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

R3

hostname R3
!
no ip cef
no ipv6 cef
!
!
license udi pid CISCO1941/K9 sn FTX1524LCOJ
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0/0
 ip address 192.168.34.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
!
interface Serial0/0/1
 ip address 192.168.3.129 255.255.255.192
 clock rate 2000000
!
interface Serial0/1/0
 ip address 192.168.23.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
!
interface Serial0/1/1
 ip address 192.168.14.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 100
 log-adjacency-changes
 area 100 authentication message-digest
 redistribute static subnets 
 network 192.168.23.0 0.0.0.255 area 100
 network 192.168.34.0 0.0.0.255 area 100
 network 192.168.14.0 0.0.0.255 area 100
 network 192.168.3.128 0.0.0.63 area 100
!
router rip
!
ip classless
ip route 172.21.1.0 255.255.255.0 192.168.3.130 
!
ip flow-export version 9
!
!
!
no cdp run
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

R4

hostname R4
!
no ip cef
no ipv6 cef
!
!
license udi pid CISCO1941/K9 sn FTX1524G5F7
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0/0
 ip address 192.168.4.129 255.255.255.192
 clock rate 2000000
!
interface Serial0/0/1
 no ip address
 clock rate 2000000
 shutdown
!
interface Serial0/1/0
 ip address 192.168.15.1 255.255.255.248
 ip ospf authentication message-digest
 ip ospf message-digest-key 1 md5 agitel
!
interface Serial0/1/1
 ip address 192.168.34.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key agitel
 ip ospf message-digest-key 1 md5 agitel
 clock rate 2000000
!
interface Vlan1
 no ip address
 shutdown
!
router ospf 100
 log-adjacency-changes
 area 100 authentication message-digest
 redistribute static subnets 
 network 192.168.34.0 0.0.0.255 area 100
 network 192.168.15.0 0.0.0.7 area 100
 network 192.168.4.128 0.0.0.63 area 100
!
ip classless
ip route 172.18.1.0 255.255.255.0 192.168.4.130 
!
ip flow-export version 9
!
no cdp run
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

围城

hostname SIEGE
!
no ip cef
no ipv6 cef
!
interface FastEthernet0/0
 no ip address
 duplex auto
 speed auto
!
interface FastEthernet0/0.2
 encapsulation dot1Q 99
 ip address 10.10.10.3 255.255.255.0
!
interface FastEthernet0/0.3
 encapsulation dot1Q 100
 ip address 10.100.100.3 255.255.255.0
!
interface FastEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/0
 ip address 192.168.1.130 255.255.255.192
!
interface Serial0/1
 no ip address
 clock rate 2000000
 shutdown
!
ip classless
ip route 192.168.12.0 255.255.255.248 192.168.1.129 
ip route 192.168.15.0 255.255.255.248 192.168.1.129 
ip route 192.168.14.0 255.255.255.0 192.168.1.129 
ip route 192.168.23.0 255.255.255.0 192.168.1.129 
ip route 192.168.34.0 255.255.255.0 192.168.1.129 
ip route 192.168.2.128 255.255.255.192 192.168.1.129 
ip route 192.168.3.128 255.255.255.192 192.168.1.129 
ip route 192.168.4.128 255.255.255.192 192.168.1.129 
!
ip flow-export version 9
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

Α

hostname ALPHA
!
no ip cef
no ipv6 cef
!
license udi pid CISCO1941/K9 sn FTX15242012
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 ip address 172.21.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/1/0
 ip address 192.168.3.130 255.255.255.192
!
interface Serial0/1/1
 no ip address
 clock rate 2000000
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
ip route 192.168.23.0 255.255.255.0 192.168.3.129 
ip route 192.168.2.128 255.255.255.192 192.168.3.129 
ip route 192.168.12.0 255.255.255.248 192.168.3.129 
ip route 192.168.1.128 255.255.255.192 192.168.3.129 
ip route 192.168.14.0 255.255.255.0 192.168.3.129 
ip route 192.168.34.0 255.255.255.0 192.168.3.129 
ip route 192.168.15.0 255.255.255.248 192.168.3.129 
ip route 192.168.4.128 255.255.255.192 192.168.3.129 
!
ip flow-export version 9
!
no cdp run
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

测试版

hostname BETA
!
no ip cef
no ipv6 cef
!
license udi pid CISCO1941/K9 sn FTX1524U7E9
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 ip address 172.18.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/1/0
 ip address 192.168.4.130 255.255.255.192
!
interface Serial0/1/1
 no ip address
 clock rate 2000000
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
ip route 192.168.34.0 255.255.255.0 192.168.4.129 
ip route 192.168.23.0 255.255.255.0 192.168.4.129 
ip route 192.168.14.0 255.255.255.0 192.168.4.129 
ip route 192.168.2.128 255.255.255.192 192.168.4.129 
ip route 192.168.3.128 255.255.255.192 192.168.4.129 
ip route 192.168.1.128 255.255.255.192 192.168.4.129 
ip route 192.168.12.0 255.255.255.248 192.168.4.129 
ip route 192.168.15.0 255.255.255.248 192.168.4.129 
!
ip flow-export version 9
!
no cdp run
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

TT

hostname TT
!
no ip cef
no ipv6 cef
!
license udi pid CISCO1941/K9 sn FTX152423MK
!
spanning-tree mode pvst
!
interface GigabitEthernet0/0
 ip address 172.23.1.1 255.255.255.0
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 no ip address
 duplex auto
 speed auto
 shutdown
!
interface Serial0/1/0
 ip address 192.168.2.130 255.255.255.192
!
interface Serial0/1/1
 no ip address
 clock rate 2000000
 shutdown
!
interface Vlan1
 no ip address
 shutdown
!
router rip
 network 192.168.23.0
!
ip classless
ip route 192.168.12.0 255.255.255.248 192.168.2.129 
ip route 192.168.1.128 255.255.255.192 192.168.2.129 
ip route 192.168.23.0 255.255.255.0 192.168.2.129 
ip route 192.168.14.0 255.255.255.0 192.168.2.129 
ip route 192.168.34.0 255.255.255.0 192.168.2.129 
ip route 192.168.15.0 255.255.255.248 192.168.2.129 
ip route 192.168.3.128 255.255.255.192 192.168.2.129 
ip route 192.168.4.128 255.255.255.192 192.168.2.129 
!
ip flow-export version 9
!
no cdp run
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
end

更新 2:路由表

R1 ip 路由

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
S       10.10.10.0/24 [1/0] via 192.168.1.130
S       10.100.100.0/24 [1/0] via 192.168.1.130
     172.18.0.0/24 is subnetted, 1 subnets
O E2    172.18.1.0/24 [110/20] via 192.168.15.1, 01:22:45, Serial0/0/1
     172.21.0.0/24 is subnetted, 1 subnets
O E2    172.21.1.0/24 [110/20] via 192.168.14.1, 01:09:31, Serial0/0/0
     172.23.0.0/24 is subnetted, 1 subnets
O E2    172.23.1.0/24 [110/20] via 192.168.12.1, 01:21:42, Serial0/1/1
     192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.1.128/26 is directly connected, Serial0/1/0
L       192.168.1.129/32 is directly connected, Serial0/1/0
     192.168.2.0/26 is subnetted, 1 subnets
O       192.168.2.128/26 [110/128] via 192.168.12.1, 01:32:41, Serial0/1/1
     192.168.3.0/26 is subnetted, 1 subnets
O       192.168.3.128/26 [110/128] via 192.168.14.1, 01:32:51, Serial0/0/0
     192.168.4.0/26 is subnetted, 1 subnets
O       192.168.4.128/26 [110/128] via 192.168.15.1, 01:32:51, Serial0/0/1
     192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.12.0/29 is directly connected, Serial0/1/1
L       192.168.12.2/32 is directly connected, Serial0/1/1
     192.168.14.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.14.0/24 is directly connected, Serial0/0/0
L       192.168.14.2/32 is directly connected, Serial0/0/0
     192.168.15.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.15.0/29 is directly connected, Serial0/0/1
L       192.168.15.2/32 is directly connected, Serial0/0/1
O    192.168.23.0/24 [110/128] via 192.168.12.1, 01:32:41, Serial0/1/1
                     [110/128] via 192.168.14.1, 01:32:41, Serial0/0/0
O    192.168.34.0/24 [110/128] via 192.168.14.1, 01:32:51, Serial0/0/0
                     [110/128] via 192.168.15.1, 01:32:51, Serial0/0/1
end

R2 ip 路由

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
O E2    10.10.10.0/24 [110/20] via 192.168.12.2, 01:10:19, Serial0/1/0
O E2    10.100.100.0/24 [110/20] via 192.168.12.2, 01:10:09, Serial0/1/0
     172.18.0.0/24 is subnetted, 1 subnets
O E2    172.18.1.0/24 [110/20] via 192.168.23.2, 01:24:41, Serial0/1/1
                      [110/20] via 192.168.12.2, 01:24:41, Serial0/1/0
     172.21.0.0/24 is subnetted, 1 subnets
O E2    172.21.1.0/24 [110/20] via 192.168.23.2, 01:11:27, Serial0/1/1
     172.23.0.0/24 is subnetted, 1 subnets
S       172.23.1.0/24 [1/0] via 192.168.2.130
     192.168.1.0/26 is subnetted, 1 subnets
O       192.168.1.128/26 [110/128] via 192.168.12.2, 01:34:42, Serial0/1/0
     192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.2.128/26 is directly connected, Serial0/0/0
L       192.168.2.129/32 is directly connected, Serial0/0/0
     192.168.3.0/26 is subnetted, 1 subnets
O       192.168.3.128/26 [110/128] via 192.168.23.2, 01:34:32, Serial0/1/1
     192.168.4.0/26 is subnetted, 1 subnets
O       192.168.4.128/26 [110/192] via 192.168.23.2, 01:34:32, Serial0/1/1
                         [110/192] via 192.168.12.2, 01:34:32, Serial0/1/0
     192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.12.0/29 is directly connected, Serial0/1/0
L       192.168.12.1/32 is directly connected, Serial0/1/0
O    192.168.14.0/24 [110/128] via 192.168.23.2, 01:34:32, Serial0/1/1
                     [110/128] via 192.168.12.2, 01:34:32, Serial0/1/0
     192.168.15.0/29 is subnetted, 1 subnets
O       192.168.15.0/29 [110/128] via 192.168.12.2, 01:34:42, Serial0/1/0
     192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.23.0/24 is directly connected, Serial0/1/1
L       192.168.23.1/32 is directly connected, Serial0/1/1
O    192.168.34.0/24 [110/128] via 192.168.23.2, 01:34:32, Serial0/1/1

R3 ip 路由

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
O E2    10.10.10.0/24 [110/20] via 192.168.14.2, 01:10:58, Serial0/1/1
O E2    10.100.100.0/24 [110/20] via 192.168.14.2, 01:10:48, Serial0/1/1
     172.18.0.0/24 is subnetted, 1 subnets
O E2    172.18.1.0/24 [110/20] via 192.168.34.2, 01:25:20, Serial0/0/0
     172.21.0.0/24 is subnetted, 1 subnets
S       172.21.1.0/24 [1/0] via 192.168.3.130
     172.23.0.0/24 is subnetted, 1 subnets
O E2    172.23.1.0/24 [110/20] via 192.168.23.1, 01:24:17, Serial0/1/0
     192.168.1.0/26 is subnetted, 1 subnets
O       192.168.1.128/26 [110/128] via 192.168.14.2, 01:35:21, Serial0/1/1
     192.168.2.0/26 is subnetted, 1 subnets
O       192.168.2.128/26 [110/128] via 192.168.23.1, 01:35:21, Serial0/1/0
     192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.3.128/26 is directly connected, Serial0/0/1
L       192.168.3.129/32 is directly connected, Serial0/0/1
     192.168.4.0/26 is subnetted, 1 subnets
O       192.168.4.128/26 [110/128] via 192.168.34.2, 01:35:11, Serial0/0/0
     192.168.12.0/29 is subnetted, 1 subnets
O       192.168.12.0/29 [110/128] via 192.168.23.1, 01:35:21, Serial0/1/0
                        [110/128] via 192.168.14.2, 01:35:21, Serial0/1/1
     192.168.14.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.14.0/24 is directly connected, Serial0/1/1
L       192.168.14.1/32 is directly connected, Serial0/1/1
     192.168.15.0/29 is subnetted, 1 subnets
O       192.168.15.0/29 [110/128] via 192.168.34.2, 01:35:11, Serial0/0/0
                        [110/128] via 192.168.14.2, 01:35:11, Serial0/1/1
     192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.23.0/24 is directly connected, Serial0/1/0
L       192.168.23.2/32 is directly connected, Serial0/1/0
     192.168.34.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.34.0/24 is directly connected, Serial0/0/0
L       192.168.34.1/32 is directly connected, Serial0/0/0

R4 ip 路由

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
O E2    10.10.10.0/24 [110/20] via 192.168.15.2, 01:11:34, Serial0/1/0
O E2    10.100.100.0/24 [110/20] via 192.168.15.2, 01:11:24, Serial0/1/0
     172.18.0.0/24 is subnetted, 1 subnets
S       172.18.1.0/24 [1/0] via 192.168.4.130
     172.21.0.0/24 is subnetted, 1 subnets
O E2    172.21.1.0/24 [110/20] via 192.168.34.1, 01:12:43, Serial0/1/1
     172.23.0.0/24 is subnetted, 1 subnets
O E2    172.23.1.0/24 [110/20] via 192.168.34.1, 01:24:53, Serial0/1/1
                      [110/20] via 192.168.15.2, 01:24:53, Serial0/1/0
     192.168.1.0/26 is subnetted, 1 subnets
O       192.168.1.128/26 [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.2.0/26 is subnetted, 1 subnets
O       192.168.2.128/26 [110/192] via 192.168.34.1, 01:36:02, Serial0/1/1
                         [110/192] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.3.0/26 is subnetted, 1 subnets
O       192.168.3.128/26 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
     192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.4.128/26 is directly connected, Serial0/0/0
L       192.168.4.129/32 is directly connected, Serial0/0/0
     192.168.12.0/29 is subnetted, 1 subnets
O       192.168.12.0/29 [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
O    192.168.14.0/24 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
                     [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.15.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.15.0/29 is directly connected, Serial0/1/0
L       192.168.15.1/32 is directly connected, Serial0/1/0
O    192.168.23.0/24 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
     192.168.34.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.34.0/24 is directly connected, Serial0/1/1
L       192.168.34.2/32 is directly connected, Serial0/1/1

围攻ip路由

Gateway of last resort is not set

     10.0.0.0/24 is subnetted, 2 subnets
O E2    10.10.10.0/24 [110/20] via 192.168.15.2, 01:11:34, Serial0/1/0
O E2    10.100.100.0/24 [110/20] via 192.168.15.2, 01:11:24, Serial0/1/0
     172.18.0.0/24 is subnetted, 1 subnets
S       172.18.1.0/24 [1/0] via 192.168.4.130
     172.21.0.0/24 is subnetted, 1 subnets
O E2    172.21.1.0/24 [110/20] via 192.168.34.1, 01:12:43, Serial0/1/1
     172.23.0.0/24 is subnetted, 1 subnets
O E2    172.23.1.0/24 [110/20] via 192.168.34.1, 01:24:53, Serial0/1/1
                      [110/20] via 192.168.15.2, 01:24:53, Serial0/1/0
     192.168.1.0/26 is subnetted, 1 subnets
O       192.168.1.128/26 [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.2.0/26 is subnetted, 1 subnets
O       192.168.2.128/26 [110/192] via 192.168.34.1, 01:36:02, Serial0/1/1
                         [110/192] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.3.0/26 is subnetted, 1 subnets
O       192.168.3.128/26 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
     192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.4.128/26 is directly connected, Serial0/0/0
L       192.168.4.129/32 is directly connected, Serial0/0/0
     192.168.12.0/29 is subnetted, 1 subnets
O       192.168.12.0/29 [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
O    192.168.14.0/24 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
                     [110/128] via 192.168.15.2, 01:36:02, Serial0/1/0
     192.168.15.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.15.0/29 is directly connected, Serial0/1/0
L       192.168.15.1/32 is directly connected, Serial0/1/0
O    192.168.23.0/24 [110/128] via 192.168.34.1, 01:36:02, Serial0/1/1
     192.168.34.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.34.0/24 is directly connected, Serial0/1/1
L       192.168.34.2/32 is directly connected, Serial0/1/1

ALPHA ip 路由

Gateway of last resort is not set

     172.21.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.21.1.0/24 is directly connected, GigabitEthernet0/0
L       172.21.1.1/32 is directly connected, GigabitEthernet0/0
     192.168.1.0/26 is subnetted, 1 subnets
S       192.168.1.128/26 [1/0] via 192.168.3.129
     192.168.2.0/26 is subnetted, 1 subnets
S       192.168.2.128/26 [1/0] via 192.168.3.129
     192.168.3.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.3.128/26 is directly connected, Serial0/1/0
L       192.168.3.130/32 is directly connected, Serial0/1/0
     192.168.4.0/26 is subnetted, 1 subnets
S       192.168.4.128/26 [1/0] via 192.168.3.129
     192.168.12.0/29 is subnetted, 1 subnets
S       192.168.12.0/29 [1/0] via 192.168.3.129
S    192.168.14.0/24 [1/0] via 192.168.3.129
     192.168.15.0/29 is subnetted, 1 subnets
S       192.168.15.0/29 [1/0] via 192.168.3.129
S    192.168.23.0/24 [1/0] via 192.168.3.129
S    192.168.34.0/24 [1/0] via 192.168.3.129

测试版 IP 路由

Gateway of last resort is not set

     172.18.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.18.1.0/24 is directly connected, GigabitEthernet0/0
L       172.18.1.1/32 is directly connected, GigabitEthernet0/0
     192.168.1.0/26 is subnetted, 1 subnets
S       192.168.1.128/26 [1/0] via 192.168.4.129
     192.168.2.0/26 is subnetted, 1 subnets
S       192.168.2.128/26 [1/0] via 192.168.4.129
     192.168.3.0/26 is subnetted, 1 subnets
S       192.168.3.128/26 [1/0] via 192.168.4.129
     192.168.4.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.4.128/26 is directly connected, Serial0/1/0
L       192.168.4.130/32 is directly connected, Serial0/1/0
     192.168.12.0/29 is subnetted, 1 subnets
S       192.168.12.0/29 [1/0] via 192.168.4.129
S    192.168.14.0/24 [1/0] via 192.168.4.129
     192.168.15.0/29 is subnetted, 1 subnets
S       192.168.15.0/29 [1/0] via 192.168.4.129
S    192.168.23.0/24 [1/0] via 192.168.4.129
S    192.168.34.0/24 [1/0] via 192.168.4.129

TT ip 路由

Gateway of last resort is not set

     172.23.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.23.1.0/24 is directly connected, GigabitEthernet0/0
L       172.23.1.1/32 is directly connected, GigabitEthernet0/0
     192.168.1.0/26 is subnetted, 1 subnets
S       192.168.1.128/26 [1/0] via 192.168.2.129
     192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks
C       192.168.2.128/26 is directly connected, Serial0/1/0
L       192.168.2.130/32 is directly connected, Serial0/1/0
     192.168.3.0/26 is subnetted, 1 subnets
S       192.168.3.128/26 [1/0] via 192.168.2.129
     192.168.4.0/26 is subnetted, 1 subnets
S       192.168.4.128/26 [1/0] via 192.168.2.129
     192.168.12.0/29 is subnetted, 1 subnets
S       192.168.12.0/29 [1/0] via 192.168.2.129
S    192.168.14.0/24 [1/0] via 192.168.2.129
     192.168.15.0/29 is subnetted, 1 subnets
S       192.168.15.0/29 [1/0] via 192.168.2.129
S    192.168.23.0/24 [1/0] via 192.168.2.129
S    192.168.34.0/24 [1/0] via 192.168.2.129
2个回答

真正的问题是:为什么 R1 和 R6 不在它们的接口上运行 OSPF?OSPF 实现具有passive-interface允许 OSPF 不跨接口共享信息同时仍允许将该接口的子网添加到 OSPF 数据库的功能。这正是我们想要的叶子网接口,例如 PC1 和 PC2 的接口。

路由器之间的静态路由是一个糟糕的主意。与混合使用 OSPF 和静态路由相比,使用每个接口运行 OSPF 来配置和操作整个网络更容易。这是许多刚开始的网络设计人员忽略的一点,因此使他们的网络更加复杂,错误地认为他们正在使它们变得更简单。

但要给出答案。R2在OSPF中有接口BC、R2-R3、R2-R4、R2-R5。R2 的配置看起来像router ospf 1, network (subnet of B-C) area 0, network (subnet of R2-R3) area 0, network (subnet of R2-R4) area 0, network (subnet of R2-R5) area 0. 在 R2 上为 10.0.0.0/8 创建一个静态路由,下一跳是 B: 的地址ip route 10.0.0.0 255.0.0.0 (address of B)然后在 R2 上将此静态路由添加到 OSPF:router ospf 1, redistribute static route-map A route-map A permit 10, match ip address prefix-list A, ip prefix-list A permit 10.0.0.0/8A路由图允许网络 10.0.0.0/8。

您会注意到我们使用路由映射来控制进入重新分配的每条路由。这是因为很容易在主 OSPF 路由表中添加我们不想要的静态路由(例如,作为丢弃目的地)。您还会注意到我们对前缀进行了完全匹配,因为这是防止令人讨厌的意外的最佳行为。

我们只在离静态网段最近的 OSPF 路由器上配置静态路由及其重新分配到 OSPF 中。在此网络中,每个静态路由都只配置和重新分配一次(R2 为 10.0.0.0/8,R5 为 20.0.0.0/8)。静态路由的多重定义和多重重新分配是一个常见的误解,信任 OSPF 来承载它已经提供的路由信息​​。

R5 的配置与 R2 类似。

R3 和 R4 没有静态路由,没有重新分配。您只需列出接口子网router ospf ..., network ... area 0, network ... area 0, ...

如果在 OSPF 路由中包含 R2 C 接口和 R5 D 接口,则需要在 R2 上设置到 R1 A 网络的静态路由,在 R5 上设置到 R6 F 网络的静态路由,并重新分配静态路由到 OSPF。同时,您可以在 R1 上创建指向 R2 的静态默认路由,在 R6 上创建指向 R5 的静态默认路由。

由于您没有包括路由器配置(在提出这样的问题时您应该这样做),我无法向您提供详细信息。


编辑:

您将无法从任何其他 PC 访问任何 PC 网络,因为带有 PC 的路由器没有通往这些其他网络的路由。

正如我所建议的,您应该在这些路由器上使用默认路由:

TT:

no ip route 192.168.12.0 255.255.255.248 192.168.2.129 
no ip route 192.168.1.128 255.255.255.192 192.168.2.129 
no ip route 192.168.23.0 255.255.255.0 192.168.2.129 
no ip route 192.168.14.0 255.255.255.0 192.168.2.129 
no ip route 192.168.34.0 255.255.255.0 192.168.2.129 
no ip route 192.168.15.0 255.255.255.248 192.168.2.129 
no ip route 192.168.3.128 255.255.255.192 192.168.2.129 
no ip route 192.168.4.128 255.255.255.192 192.168.2.129 
ip route 0.0.0.0 0.0.0.0 192.168.2.129 
!

Α:

no ip route 192.168.23.0 255.255.255.0 192.168.3.129 
no ip route 192.168.2.128 255.255.255.192 192.168.3.129 
no ip route 192.168.12.0 255.255.255.248 192.168.3.129 
no ip route 192.168.1.128 255.255.255.192 192.168.3.129 
no ip route 192.168.14.0 255.255.255.0 192.168.3.129 
no ip route 192.168.34.0 255.255.255.0 192.168.3.129 
no ip route 192.168.15.0 255.255.255.248 192.168.3.129 
no ip route 192.168.4.128 255.255.255.192 192.168.3.129 
ip route 0.0.0.0 0.0.0.0 192.168.3.129 
!

测试版:

no ip route 192.168.34.0 255.255.255.0 192.168.4.129 
no ip route 192.168.23.0 255.255.255.0 192.168.4.129 
no ip route 192.168.14.0 255.255.255.0 192.168.4.129 
no ip route 192.168.2.128 255.255.255.192 192.168.4.129 
no ip route 192.168.3.128 255.255.255.192 192.168.4.129 
no ip route 192.168.1.128 255.255.255.192 192.168.4.129 
no ip route 192.168.12.0 255.255.255.248 192.168.4.129 
no ip route 192.168.15.0 255.255.255.248 192.168.4.129 
ip route 0.0.0.0 0.0.0.0 192.168.4.129 
!