如下图示:
R1: interface Loopback0 ip address 1.1.1.1 255.255.255.255 interface FastEthernet1/0 ip address 12.1.1.1 255.255.255.0 no sh router ospf 1 router-id 1.1.1.1 network 1.1.1.1 0.0.0.0 area 0 network 12.1.1.0 0.0.0.255 area 0 R2: interface Loopback0 ip address 2.2.2.2 255.255.255.255 interface FastEthernet0/0 ip address 23.1.1.2 255.255.255.0 no sh interface FastEthernet0/1 ip address 24.1.1.2 255.255.255.0 no sh interface FastEthernet1/0 ip address 12.1.1.2 255.255.255.0 no sh router ospf 1 area 1 stub network 2.2.2.2 0.0.0.0 area 0 network 12.1.1.0 0.0.0.255 area 0 network 23.1.1.0 0.0.0.255 area 1 network 24.1.1.0 0.0.0.255 area 1 R3: interface Loopback0 ip address 3.3.3.3 255.255.255.255 interface FastEthernet0/0 ip address 23.1.1.3 255.255.255.0 no sh router ospf 1 router-id 3.3.3.3 area 1 stub network 3.3.3.3 0.0.0.0 area 1 network 23.1.1.0 0.0.0.255 area 1 R4: interface Loopback0 ip address 4.4.4.4 255.255.255.255 interface FastEthernet0/1 ip address 24.1.1.4 255.255.255.0 no sh router ospf 1 router-id 4.4.4.4 area 1 stub network 4.4.4.4 0.0.0.0 area 1 network 24.1.1.0 0.0.0.255 area 1 R1(config-router)#do 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 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/2] via 12.1.1.2, 00:30:41, FastEthernet1/0 3.0.0.0/32 is subnetted, 1 subnets O IA 3.3.3.3 [110/12] via 12.1.1.2, 00:22:52, FastEthernet1/0 4.0.0.0/32 is subnetted, 1 subnets O IA 4.4.4.4 [110/12] via 12.1.1.2, 00:25:54, FastEthernet1/0 23.0.0.0/24 is subnetted, 1 subnets O IA 23.1.1.0 [110/11] via 12.1.1.2, 00:30:38, FastEthernet1/0 24.0.0.0/24 is subnetted, 1 subnets O IA 24.1.1.0 [110/11] via 12.1.1.2, 00:30:29, FastEthernet1/0 12.0.0.0/24 is subnetted, 1 subnets C 12.1.1.0 is directly connected, FastEthernet1/0 R4(config-router)# do 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 24.1.1.2 to network 0.0.0.0 1.0.0.0/32 is subnetted, 1 subnets O IA 1.1.1.1 [110/12] via 24.1.1.2, 00:23:29, FastEthernet0/1 2.0.0.0/32 is subnetted, 1 subnets O IA 2.2.2.2 [110/11] via 24.1.1.2, 00:23:29, FastEthernet0/1 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/21] via 24.1.1.2, 00:23:29, FastEthernet0/1 4.0.0.0/32 is subnetted, 1 subnets C 4.4.4.4 is directly connected, Loopback0 23.0.0.0/24 is subnetted, 1 subnets O 23.1.1.0 [110/20] via 24.1.1.2, 00:23:31, FastEthernet0/1 24.0.0.0/24 is subnetted, 1 subnets C 24.1.1.0 is directly connected, FastEthernet0/1 12.0.0.0/24 is subnetted, 1 subnets O IA 12.1.1.0 [110/11] via 24.1.1.2, 00:23:31, FastEthernet0/1 O*IA 0.0.0.0/0 [110/11] via 24.1.1.2, 00:23:31, FastEthernet0/1 R4(config-router)#do ping 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 24/36/52 ms R1(config-router)#do ping 4.4.4.4 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/32/40 ms