R1配置:
R1(config)#int lo0
                                 //设置本地环回接口IP地址//
R1(config-if)#ip address 1.1.1.10 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#int f1/0
                             //给端口设置IP地址//
R1(config-if)#ip address 10.0.0.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#int f0/0
R1(config-if)#ip address 192.168.1.1 255.255.255.252
R1(config-if)#no shutdown
R1(config-if)#end
R1#conf t
R1(config)#router ospf 1
                           //启动OSPF进程//
R1(config-router)#network 192.168.1.0 0.0.0.3
R1(config-router)#network 192.168.1.0 0.0.0.3 area 0
R1(config-router)#network 10.0.0.0 0.0.0.255 area 0
R1(config-router)#end
R2配置:
R2#conf t
R2(config)#int lo0
R2(config-if)#ip address 1.1.1.9 255.255.255.255
R2(config-if)#no shutdown
R2(config-if)#int f0/0
R2(config-if)#ip address 192.168.1.2 255.255.255.252
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#router ospf 2
R2(config-router)#network 192.168.1.0 0.0.0.3 area 0
R2(config-router)#exit   
R2(config)#int f1/0
R2(config-if)#ip address 192.168.2.1 255.255.255.252
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#router ospf 2
R2(config-router)#network 192.168.2.0 0.0.0.3 area 0
R2(config-router)#end
R3配置:
R3(config)#int lo0
R3(config-if)#ip address 1.1.1.8 255.255.255.255
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#int f1/0
R3(config-if)#ip address 192.168.2.2 255.255.255.252
R3(config-if)#no shutdown
R3(config-if)#int f0/0
R3(config-if)#ip address 192.168.3.1 255.255.255.252
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#router ospf 3
R3(config-router)#network 192.168.2.0 0.0.0.3 area 0
R3(config-router)#network 192.168.3.0 0.0.0.3 area 0
R3(config-router)#end
R4配置:
R4(config)#int lo0
R4(config-if)#ip address 1.1.1.7 255.255.255.255
R4(config-if)#no shutdown
R4(config-if)#exit
R4(config)#int f0/0
R4(config-if)#ip address 192.168.3.2 255.255.255.252
R4(config-if)#no shutdown
R4(config-if)#int f1/0
R4(config-if)#ip address 172.16.0.254 255.255.255.0
R4(config-if)#no shutdown             
R4(config-if)#exit
R4(config)#router ospf 4
R4(config-router)#network 192.168.3.0 0.0.0.3 area 0
R4(config-router)#network 172.16.0.0 0.0.0.255 area 0
R4(config-router)#end
R4#show ip route
                                       //查看路由表//
Gateway of last resort is not set
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.7 is directly connected, Loopback0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.0.0 is directly connected, FastEthernet1/0
     10.0.0.0/24 is subnetted, 1 subnets
O       10.0.0.0 [110/4] via 192.168.3.1, 00:10:36, FastEthernet0/0
     192.168.1.0/30 is subnetted, 1 subnets
O       192.168.1.0 [110/3] via 192.168.3.1, 00:10:36, FastEthernet0/0
     192.168.2.0/30 is subnetted, 1 subnets
O       192.168.2.0 [110/2] via 192.168.3.1, 00:10:36, FastEthernet0/0
     192.168.3.0/30 is subnetted, 1 subnets
C       192.168.3.0 is directly connected, FastEthernet0/0
客户机配置:
PC1:
IP:10.0.0.1/24
GW:10.0.0.254
PC2:
IP:172.16.0.1/24
GW:172.16.0.254
测试:
PC1#ping 172.16.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 408/503/648 ms