拓扑图

 

实验过程

1.       R1的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host  R1

R1(config)#int lo0

R1(config-if)#ip add 10.1.1.1 255.255.255.0

R1(config-if)#int lo1

R1(config-if)#ip add 10.1.2.1 255.255.255.0

R1(config-if)#int s0/0

R1(config-if)#no shut

R1(config-if)#ip add 192.168.1.1 255.255.255.252

R1(config-if)#exit

2.       R2的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host  R2

R2(config)#int s0/0

R2(config-if)#no shut

R2(config-if)#ip add 192.168.1.2 255.255.255.252

R2(config-if)#int s0/1

R2(config-if)#no shut

R2(config-if)#ip add 192.168.1.5 255.255.255.252

R2(config-if)#exit

3.       R3的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host  R3

R3(config)#int s0/1

R3(config-if)#no shut

R3(config-if)#ip add 192.168.1.6 255.255.255.252

R3(config-if)#int s0/2

R3(config-if)#no shut

R3(config-if)#ip add 192.168.1.9 255.255.255.252

R3(config-if)#exit

4.       R4的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host  R4

R4(config)#int s0/2

R4(config-if)#no shut

R4(config-if)#ip add 192.168.1.10 255.255.255.252

R4(config-if)#int lo0

R4(config-if)#ip add 172.16.1.1 255.255.255.0

R4(config-if)#int lo1

R4(config-if)#ip add 172.16.2.1 255.255.255.0

R4(config-if)#exit

5.       R1OSPF配置

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#net 192.168.1.1 0.0.0.0 area 1

R1(config-router)#net 10.1.1.1 0.0.0.0 area 1

R1(config-router)#net 10.1.2.1 0.0.0.0 area 1

R1(config-router)#end

 

6.       R2OSPF配置

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#net 192.168.1.2 0.0.0.0 area 1

R2(config-router)#net 192.168.1.5 0.0.0.0 area 0

R2(config-router)#end

7.       R3OSPF配置

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#net 192.168.1.6 0.0.0.0 area 0

R3(config-router)#net 192.168.1.9 0.0.0.0 area 2

R3(config-router)#end

8.       R4OSPF配置

R4(config)#router ospf 1

R4(config-router)#router-id 4.4.4.4

Reload or use "clear ip ospf process" command, for this to take effect

R4(config-router)#net 192.168.1.10 0.0.0.0 area 2

R4(config-router)#net 172.16.1.1 0.0.0.0 area 2

R4(config-router)#net 172.16.2.1 0.0.0.0 area 2

R4(config-router)#end

9.       查看R2R3的邻居表

R2#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

3.3.3.3           0   FULL/  -        00:00:37    192.168.1.6     Serial0/1

1.1.1.1           0   FULL/  -        00:00:31    192.168.1.1     Serial0/0

R3#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2.2           0   FULL/  -        00:00:30    192.168.1.5     Serial0/1

4.4.4.4           0   FULL/  -        00:00:30    192.168.1.10    Serial0/2

10.   查看R2的链路状态数据库

R2#show ip ospf da

 

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

 

                Router Link States (Area 0)  //LSA 1

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

2.2.2.2         2.2.2.2         156         0x80000006 0x002B7C 2

3.3.3.3         3.3.3.3         762         0x80000005 0x00CCD6 2

 

                Summary Net Link States (Area 0)  //LSA 3

 

Link ID         ADV Router      Age         Seq#       Checksum

10.1.1.1        2.2.2.2         152         0x80000001 0x0036B0

10.1.2.1        2.2.2.2         152         0x80000001 0x002BBA

172.16.1.1      3.3.3.3         757         0x80000001 0x002110

172.16.2.1      3.3.3.3         757         0x80000001 0x00161A

192.168.1.0     2.2.2.2         152         0x80000001 0x00018C

192.168.1.8     3.3.3.3         757         0x80000001 0x0092EE

 

                Router Link States (Area 1)  //LSA 1

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

1.1.1.1         1.1.1.1         157         0x80000003 0x000C76 4

2.2.2.2         2.2.2.2         156         0x80000001 0x006E4D 2

 

                Summary Net Link States (Area 1)  //LSA 3

 

Link ID         ADV Router      Age         Seq#       Checksum

172.16.1.1      2.2.2.2         158         0x80000001 0x00C133

172.16.2.1      2.2.2.2         158         0x80000001 0x00B63D

192.168.1.4     2.2.2.2         158         0x80000001 0x00D8B0

192.168.1.8    2.2.2.2         158         0x80000001 0x003312

11.   查看R4的路由表

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

 

     172.16.0.0/24 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, Loopback0

C       172.16.2.0 is directly connected, Loopback1

     10.0.0.0/32 is subnetted, 2 subnets

O IA    10.1.2.1 [110/193] via 192.168.1.9, 00:14:14, Serial0/2

O IA    10.1.1.1 [110/193] via 192.168.1.9, 00:14:14, Serial0/2

     192.168.1.0/30 is subnetted, 3 subnets

C       192.168.1.8 is directly connected, Serial0/2

O IA    192.168.1.0 [110/192] via 192.168.1.9, 00:14:14, Serial0/2

O IA    192.168.1.4 [110/128] via 192.168.1.9, 00:14:14, Serial0/2

R4R1学到的不是汇总的路由,OSPF默认不对路由进行汇总。

 

12.   测试连通性

R1#ping 172.16.1.1 source lo0   

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:

Packet sent with a source address of 10.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/67/108 ms

R1#ping 172.16.1.1 source lo1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:

Packet sent with a source address of 10.1.2.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/56/124 ms

13.   R2上做区域间路由汇总

R2(config)#router ospf 1

R2(config-router)#area 1 range 10.1.0.0 255.255.252.0  //区域间汇总在ABR上配置

R2(config-router)#end

14.   再次测试连通性

R4#ping 10.1.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/57/76 ms

R4#ping 10.1.2.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 44/84/104 ms