1,配置基本ospf,由于area3 和area0隔离,配置虚链路,把rip和ospf相互重分发。2,配置totally stub和totally nssa区域。3,进行域外和域间的汇总

r1:

interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.1.1.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.1.1.13 255.255.255.252
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 network 1.1.1.0 0.0.0.255 area 0
 network 192.1.1.0 0.0.0.3 area 0
 network 192.1.1.12 0.0.0.3 area 0

r2:

r2(config)#router ospf 10
r2(config-router)#ar
r2(config-router)#area 2 ns
r2(config-router)#area 2 nssa no
r2(config-router)#area 2 nssa no-su
r2(config-router)#area 2 nssa no-summary
r2(config-router)#no ar
r2(config-router)#no area 2 ns
r2(config-router)#no area 2 nssa no
r2(config-router)#no area 2 nssa no-su
r2(config-router)#no area 2 nssa no-summary
r2(config-router)#ar
r2(config-router)#area 1 ns
r2(config-router)#area 1 nssa no
r2(config-router)#area 1 nssa no-su
r2(config-router)#area 1 nssa no-summary

r3:

interface Loopback0
 ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
 ip address 192.1.1.9 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.1.1.6 255.255.255.252
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 redistribute rip subnets                           把rip重分发进ospf,如果没有加subnets,将忽略子网路由
 network 3.3.3.0 0.0.0.255 area 1
 network 192.1.1.4 0.0.0.3 area 1
!
router rip
 version 2
 redistribute ospf 10 metric 2                 把ospf重分发进ospf中
 network 192.1.1.0
 no auto-summary

r4:

interface Loopback0
 ip address 4.4.4.4 255.255.255.0
!
interface Loopback1
 no ip address
!
interface Loopback2
 no ip address
!        
interface Loopback3
 no ip address
!
interface FastEthernet0/0
 ip address 192.1.1.17 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.1.1.14 255.255.255.252
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 area 2 virtual-link 5.5.5.5                            //配置虚链路,指定对方的router-id
 network 4.4.4.0 0.0.0.255 area 2
 network 192.1.1.12 0.0.0.3 area 0
 network 192.1.1.16 0.0.0.3 area 2

r5:

interface Loopback0
 ip address 5.5.5.5 255.255.255.0
!
interface Loopback1
 no ip address
!
interface Loopback2
 no ip address
!        
interface Loopback3
 no ip address
!
interface Loopback5
 no ip address
!
interface Loopback6
 no ip address
!
interface FastEthernet0/0
 ip address 192.1.1.18 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.1.1.21 255.255.255.252
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 area 2 virtual-link 4.4.4.4                        //配置虚链路,指定对方的router-id
 network 5.5.5.0 0.0.0.255 area 2
 network 192.1.1.16 0.0.0.3 area 2
 network 192.1.1.20 0.0.0.3 area 3

r6:

interface Loopback0
 ip address 6.6.6.6 255.255.255.0
!
interface Loopback1
 no ip address
 ip ospf network point-to-point
!
interface FastEthernet0/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
interface FastEthernet1/0
 ip address 192.1.1.22 255.255.255.252
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
 network 6.6.6.0 0.0.0.255 area 3
 network 192.1.1.20 0.0.0.3 area 3

r7:

interface Loopback0
 ip address 7.7.7.7 255.255.255.0
!
interface Loopback1
 no ip address
!
interface Loopback2
 no ip address
!        
interface Loopback3
 no ip address
!
interface FastEthernet0/0
 ip address 192.1.1.10 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet1/0
 no ip address
 shutdown
 duplex auto
 speed auto
!
router ospf 10
 log-adjacency-changes
!
router rip
 version 2
 network 7.0.0.0
 network 192.1.1.0
 no auto-summary

看一下r4的路由表

r4#sh 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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.1.1.13, 00:49:37, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/3] via 192.1.1.13, 00:49:37, FastEthernet1/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/4] via 192.1.1.13, 00:01:18, FastEthernet1/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.1.1.18, 01:35:21, FastEthernet0/0
     6.0.0.0/32 is subnetted, 1 subnets
O IA    6.6.6.6 [110/3] via 192.1.1.18, 00:00:32, FastEthernet0/0
     7.0.0.0/24 is subnetted, 1 subnets
O E2    7.7.7.0 [110/20] via 192.1.1.13, 00:00:29, FastEthernet1/0
     192.1.1.0/30 is subnetted, 6 subnets
O       192.1.1.0 [110/2] via 192.1.1.13, 00:49:39, FastEthernet1/0
O IA    192.1.1.4 [110/3] via 192.1.1.13, 00:01:09, FastEthernet1/0
O E2    192.1.1.8 [110/20] via 192.1.1.13, 00:00:29, FastEthernet1/0
C       192.1.1.12 is directly connected, FastEthernet1/0
C       192.1.1.16 is directly connected, FastEthernet0/0
O IA    192.1.1.20 [110/2] via 192.1.1.18, 00:00:34, FastEthernet0/0

能够学到全网路由,下面配置totally nssa和totally stub区域

r2(config)#router ospf 10
r2(config-router)#area 1 nssa no-summary

r3(config)#router ospf 10
r3(config-router)#area 1 nssa

r5(config)#router ospf 10
r5(config-router)#area 3 stub no-summary

r6(config)#router ospf 10
r6(config-router)#area 3 stub

看一下路由表

r3#sh 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 192.1.1.5 to network 0.0.0.0

     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/2] via 192.1.1.5, 00:01:59, FastEthernet1/0
     3.0.0.0/24 is subnetted, 1 subnets
C       3.3.3.0 is directly connected, Loopback0
     7.0.0.0/24 is subnetted, 1 subnets
R       7.7.7.0 [120/1] via 192.1.1.10, 00:00:12, FastEthernet0/0
     192.1.1.0/30 is subnetted, 2 subnets
C       192.1.1.4 is directly connected, FastEthernet1/0
C       192.1.1.8 is directly connected, FastEthernet0/0
O*IA 0.0.0.0/0 [110/2] via 192.1.1.5, 00:01:59, FastEthernet1/0

totally nssa区域中,r3除了本区域的路由和直连的外部自治系统的路由,只有一条默认路由和其他区域通信。

r6#sh 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 192.1.1.21 to network 0.0.0.0

     6.0.0.0/24 is subnetted, 1 subnets
C       6.6.6.0 is directly connected, Loopback0
     192.1.1.0/30 is subnetted, 1 subnets
C       192.1.1.20 is directly connected, FastEthernet1/0
O*IA 0.0.0.0/0 [110/2] via 192.1.1.21, 00:02:18, FastEthernet1/0

r6在totally stub 区域中,因此只允许LSA1,LSA2,和由ABR通告的一条LSA3的默认路由存在

下面配置域外路由汇总

r7(config)#interface loopback 1
r7(config-if)#ip add 100.1.1.1 255.255.255.0
r7(config-if)#inter lo 2
r7(config-if)#ip add 100.1.2.1 255.255.255.0
r7(config-if)#inter lo 3
r7(config-if)#ip add 100.1.3.1 255.255.255.0
r7(config)#router rip
r7(config-router)#version 2
r7(config-router)#network 100.1.1.0
r7(config-router)#network 100.1.2.0
r7(config-router)#network 100.1.3.0

看一下r4的路由表,已经学到了100段的子网

r4# sh 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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.1.1.13, 01:06:48, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/3] via 192.1.1.13, 01:06:48, FastEthernet1/0
     100.0.0.0/24 is subnetted, 3 subnets
O E2    100.1.1.0 [110/20] via 192.1.1.13, 00:00:20, FastEthernet1/0
O E2    100.1.3.0 [110/20] via 192.1.1.13, 00:00:20, FastEthernet1/0
O E2    100.1.2.0 [110/20] via 192.1.1.13, 00:00:20, FastEthernet1/0

     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/4] via 192.1.1.13, 00:08:57, FastEthernet1/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.1.1.18, 01:52:31, FastEthernet0/0
     6.0.0.0/32 is subnetted, 1 subnets
O IA    6.6.6.6 [110/3] via 192.1.1.18, 00:07:22, FastEthernet0/0
     7.0.0.0/24 is subnetted, 1 subnets
O E2    7.7.7.0 [110/20] via 192.1.1.13, 00:07:17, FastEthernet1/0
     192.1.1.0/30 is subnetted, 6 subnets
O       192.1.1.0 [110/2] via 192.1.1.13, 01:06:49, FastEthernet1/0
O IA    192.1.1.4 [110/3] via 192.1.1.13, 00:09:03, FastEthernet1/0
O E2    192.1.1.8 [110/20] via 192.1.1.13, 00:07:17, FastEthernet1/0
C       192.1.1.12 is directly connected, FastEthernet1/0
C       192.1.1.16 is directly connected, FastEthernet0/0
O IA    192.1.1.20 [110/2] via 192.1.1.18, 00:07:40, FastEthernet0/0

在ASBR路由器上进行汇总

r3(config)#router ospf 10
r3(config-router)#summary-address 100.1.0.0 255.255.252.0    //域外路由汇总,在ASBR上用这条命令

看到r4的路由表中已经汇总了路由

r4#sh 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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.1.1.13, 01:10:07, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/3] via 192.1.1.13, 01:10:07, FastEthernet1/0
     100.0.0.0/22 is subnetted, 1 subnets
O E2    100.1.0.0 [110/20] via 192.1.1.13, 00:00:21, FastEthernet1/0

     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/4] via 192.1.1.13, 00:12:16, FastEthernet1/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.1.1.18, 01:55:51, FastEthernet0/0
     6.0.0.0/32 is subnetted, 1 subnets
O IA    6.6.6.6 [110/3] via 192.1.1.18, 00:10:47, FastEthernet0/0
     7.0.0.0/24 is subnetted, 1 subnets
O E2    7.7.7.0 [110/20] via 192.1.1.13, 00:10:42, FastEthernet1/0
     192.1.1.0/30 is subnetted, 6 subnets
O       192.1.1.0 [110/2] via 192.1.1.13, 01:10:14, FastEthernet1/0
O IA    192.1.1.4 [110/3] via 192.1.1.13, 00:12:28, FastEthernet1/0
O E2    192.1.1.8 [110/20] via 192.1.1.13, 00:10:42, FastEthernet1/0
C       192.1.1.12 is directly connected, FastEthernet1/0
C       192.1.1.16 is directly connected, FastEthernet0/0
O IA    192.1.1.20 [110/2] via 192.1.1.18, 00:11:06, FastEthernet0/0

配置一下域间路由汇总

r3(config)#interface loopback 1
r3(config-if)#ip add 200.1.1.1 255.255.255.0
r3(config-if)#inter lo 2
r3(config-if)#ip add 200.1.2.1 255.255.255.0
r3(config-if)#inter lo 3
r3(config-if)#ip add 200.1.3.1 255.255.255.0
r3(config)#router ospf 10
r3(config-router)#network 200.1.1.0 0.0.0.255 area 1
r3(config-router)#network 200.1.2.0 0.0.0.255 area 1
r3(config-router)#network 200.1.3.0 0.0.0.255 area 1

r4#sh 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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.1.1.13, 01:14:30, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/3] via 192.1.1.13, 01:14:30, FastEthernet1/0
     100.0.0.0/22 is subnetted, 1 subnets
O E2    100.1.0.0 [110/20] via 192.1.1.13, 00:00:04, FastEthernet1/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/4] via 192.1.1.13, 00:16:39, FastEthernet1/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.1.1.18, 02:00:13, FastEthernet0/0
     200.1.1.0/32 is subnetted, 1 subnets
O IA    200.1.1.1 [110/4] via 192.1.1.13, 00:00:29, FastEthernet1/0
     6.0.0.0/32 is subnetted, 1 subnets
O IA    6.6.6.6 [110/3] via 192.1.1.18, 00:15:03, FastEthernet0/0
     200.1.2.0/32 is subnetted, 1 subnets
O IA    200.1.2.1 [110/4] via 192.1.1.13, 00:00:19, FastEthernet1/0
     7.0.0.0/24 is subnetted, 1 subnets
O E2    7.7.7.0 [110/20] via 192.1.1.13, 00:00:04, FastEthernet1/0
     200.1.3.0/32 is subnetted, 1 subnets
O IA    200.1.3.1 [110/4] via 192.1.1.13, 00:00:09, FastEthernet1/0
     192.1.1.0/30 is subnetted, 6 subnets
O       192.1.1.0 [110/2] via 192.1.1.13, 01:14:30, FastEthernet1/0
O IA    192.1.1.4 [110/3] via 192.1.1.13, 00:16:44, FastEthernet1/0
O E2    192.1.1.8 [110/20] via 192.1.1.13, 00:00:04, FastEthernet1/0
C       192.1.1.12 is directly connected, FastEthernet1/0
C       192.1.1.16 is directly connected, FastEthernet0/0
O IA    192.1.1.20 [110/2] via 192.1.1.18, 00:15:22, FastEthernet0/0

r4学到了子网路由,下面在ABR上面做域间路由汇总

r2(config)#router ospf 10
r2(config-router)#area 1 range 200.1.0.0 255.255.252.0         //域间路由汇总,在ABR上用这个命令

r4#sh 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

     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/2] via 192.1.1.13, 01:15:12, FastEthernet1/0
     2.0.0.0/32 is subnetted, 1 subnets
O IA    2.2.2.2 [110/3] via 192.1.1.13, 01:15:12, FastEthernet1/0
     100.0.0.0/22 is subnetted, 1 subnets
O E2    100.1.0.0 [110/20] via 192.1.1.13, 00:00:00, FastEthernet1/0
     3.0.0.0/32 is subnetted, 1 subnets
O IA    3.3.3.3 [110/4] via 192.1.1.13, 00:17:21, FastEthernet1/0
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     5.0.0.0/32 is subnetted, 1 subnets
O       5.5.5.5 [110/2] via 192.1.1.18, 02:00:55, FastEthernet0/0
     6.0.0.0/32 is subnetted, 1 subnets
O IA    6.6.6.6 [110/3] via 192.1.1.18, 00:15:46, FastEthernet0/0
     7.0.0.0/24 is subnetted, 1 subnets
O E2    7.7.7.0 [110/20] via 192.1.1.13, 00:00:00, FastEthernet1/0
     192.1.1.0/30 is subnetted, 6 subnets
O       192.1.1.0 [110/2] via 192.1.1.13, 01:15:13, FastEthernet1/0
O IA    192.1.1.4 [110/3] via 192.1.1.13, 00:17:27, FastEthernet1/0
O E2    192.1.1.8 [110/20] via 192.1.1.13, 00:00:00, FastEthernet1/0
C       192.1.1.12 is directly connected, FastEthernet1/0
C       192.1.1.16 is directly connected, FastEthernet0/0
O IA    192.1.1.20 [110/2] via 192.1.1.18, 00:16:04, FastEthernet0/0
O IA 200.1.0.0/22 [110/4] via 192.1.1.13, 00:00:05, FastEthernet1/0

已经成了一条汇总路由

r7#ping 6.6.6.6

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

r6#ping 7.7.7.7

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

全网通