一、对各个路由器配置接口 IP ,宣告网络
R1
Router>
Router>enable
Router#config terminal
Router(config)#hostname R1-jin
R1-jin(config)#interface loopback 0
R1-jin(config-if)#ip add 1.1.1.1 255.255.255.255
R1-jin(config-if)#interface f0/0
R1-jin(config-if)#ip address 10.0.0.1 255.0.0.0
R1-jin(config-if)#no shutdown
R1-jin(config-if)#interface f1/0
R1-jin(config-if)#ip address 20.0.0.1 255.0.0.0
R1-jin(config-if)#no shutdown
R1-jin(config-if)#exit
R1-jin(config)#router ospf 1
R1-jin(config-router)#network 10.0.0.1 0.0.0.0 area 1
R1-jin(config-router)#network 20.0.0.1 0.0.0.0 area 1
R1-jin(config-router)#end
R1-jin#
R1-jin#show ip route
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
O IA 50.0.0.0/8 [110/67] via 20.0.0.2, 00:00:16, FastEthernet1/0
C 20.0.0.0/8 is directly connected, FastEthernet1/0
O IA 40.0.0.0/8 [110/66] via 20.0.0.2, 00:06:11, FastEthernet1/0
C 10.0.0.0/8 is directly connected, FastEthernet0/0
O IA 60.0.0.0/8 [110/68] via 20.0.0.2, 00:00:16, FastEthernet1/0
O IA 30.0.0.0/8 [110/2] via 20.0.0.2, 00:07:51, FastEthernet1/0
R1-jin#
R2
Router>
Router>enable
Router#config terminal
Router(config)#hostname R2-jin
R2-jin(config)#interface loopback 0
R2-jin(config-if)#ip address 2.2.2.2 255.255.255.255
R2-jin(config-if)#interface f1/0
R2-jin(config-if)#ip address 20.0.0.2 255.0.0.0
R2-jin(config-if)#no shutdown
R2-jin(config-if)#interface f0/0
R2-jin(config-if)#ip address 30.0.0.2 255.0.0.0
R2-jin(config-if)#no shutdown
R2-jin(config-if)#exit
R2-jin(config)#router ospf 1
R2-jin(config-router)#network 20.0.0.2 0.0.0.0 area 1
R2-jin(config-router)#network 30.0.0.2 0.0.0.0 area 0
R2-jin(config-router)#end
R2-jin#
R2-jin#show ip route
O IA 50.0.0.0/8 [110/66] via 30.0.0.1, 00:00:34, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
C 20.0.0.0/8 is directly connected, FastEthernet1/0
O 40.0.0.0/8 [110/65] via 30.0.0.1, 00:05:35, FastEthernet0/0
O 10.0.0.0/8 [110/2] via 20.0.0.1, 00:10:54, FastEthernet1/0
O IA 60.0.0.0/8 [110/67] via 30.0.0.1, 00:00:29, FastEthernet0/0
C 30.0.0.0/8 is directly connected, FastEthernet0/0
R2-jin#
R3
Router>
Router>enable
Router#config terminal
Router(config)#hostname R3-jin
R3-jin(config)#interface loopback 0
R3-jin(config-if)#ip address 3.3.3.3 255.255.255.255
R3-jin(config-if)#interface f0/0
R3-jin(config-if)#ip address 30.0.0.1 255.0.0.0
R3-jin(config-if)#no shutdown
R3-jin(config-if)#interface f1/0
R3-jin(config-if)#ip address 70.0.0.1 255.0.0.0
R3-jin(config-if)#no shutdown
R3-jin(config-if)#interface s2/0
R3-jin(config-if)#ip address 40.0.0.1 255.0.0.0
R3-jin(config-if)#clock rate 128000
R3-jin(config-if)#no shutdown
R3-jin(config-if)#exit
R3-jin(config)#router ospf 1
R3-jin(config-router)#network 30.0.0.1 0.0.0.0 area 0
R3-jin(config-router)#network 40.0.0.1 0.0.0.0 area 0
R3-jin(config-router)#end
R3-jin#
R3-jin#show ip route
O IA 50.0.0.0/8 [110/65] via 40.0.0.2, 00:00:45, Serial2/0
C 70.0.0.0/8 is directly connected, FastEthernet1/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
O IA 20.0.0.0/8 [110/2] via 30.0.0.2, 00:05:46, FastEthernet0/0
C 40.0.0.0/8 is directly connected, Serial2/0
O IA 10.0.0.0/8 [110/3] via 30.0.0.2, 00:05:46, FastEthernet0/0
O IA 60.0.0.0/8 [110/66] via 40.0.0.2, 00:00:40, Serial2/0
C 30.0.0.0/8 is directly connected, FastEthernet0/0
R3-jin#
R4
Router>
Router>enable
Router#config terminal
Router(config)#hostname R4-jin
R4-jin(config)#interface loopback 0
R4-jin(config-if)#ip address 4.4.4.4 255.255.255.255
R4-jin(config-if)#interface s1/0
R4-jin(config-if)#ip address 40.0.0.2 255.0.0.0
R4-jin(config-if)#clock rate 128000
R4-jin(config-if)#no shutdown
R4-jin(config-if)#interface f0/0
R4-jin(config-if)#ip address 50.0.0.1 255.0.0.0
R4-jin(config-if)#no shutdown
R4-jin(config-if)#exit
R4-jin(config)#router ospf 1
R4-jin(config-router)#network 40.0.0.2 0.0.0.0 area 0
R4-jin(config-router)#network 50.0.0.1 0.0.0.0 area 2
R4-jin(config-router)#end
R4-jin#
R4-jin#show ip route
C 50.0.0.0/8 is directly connected, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
O IA 20.0.0.0/8 [110/66] via 40.0.0.1, 00:00:47, Serial1/0
C 40.0.0.0/8 is directly connected, Serial1/0
O IA 10.0.0.0/8 [110/67] via 40.0.0.1, 00:00:47, Serial1/0
O 60.0.0.0/8 [110/2] via 50.0.0.2, 00:00:47, FastEthernet0/0
O 30.0.0.0/8 [110/65] via 40.0.0.1, 00:05:53, Serial1/0
R4-jin#
R5
Router>
Router>enable
Router#config terminal
Router(config)#hostname R5-jin
R5-jin(config)#interface loopback 0
R5-jin(config-if)#ip address 5.5.5.5 255.255.255.255
R5-jin(config-if)#interface f0/0
R5-jin(config-if)#ip address 50.0.0.2 255.0.0.0
R5-jin(config-if)#no shutdown
R5-jin(config-if)#interface f1/0
R5-jin(config-if)#ip address 60.0.0.1 255.0.0.0
R5-jin(config-if)#no shutdown
R5-jin(config-if)#exit
R5-jin(config)#router ospf 1
R5-jin(config-router)#network 50.0.0.2 0.0.0.0 area 2
R5-jin(config-router)#network 60.0.0.1 0.0.0.0 area 2
R5-jin(config-router)#end
R5-jin#
R5-jin#show ip route
C 50.0.0.0/8 is directly connected, FastEthernet0/0
O IA 20.0.0.0/8 [110/67] via 50.0.0.1, 00:00:54, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
O IA 40.0.0.0/8 [110/65] via 50.0.0.1, 00:00:54, FastEthernet0/0
O IA 10.0.0.0/8 [110/68] via 50.0.0.1, 00:00:54, FastEthernet0/0
C 60.0.0.0/8 is directly connected, FastEthernet1/0
O IA 30.0.0.0/8 [110/66] via 50.0.0.1, 00:00:54, FastEthernet0/0
R5-jin#
二、在R3上配置静态默认路由,并在OSPF进程中进行重分发,让其他路由器学习到默认路由(为动态默认路由)
R3
R3-jin#
R3-jin#config terminal
R3-jin(config)#ip route 0.0.0.0 0.0.0.0 70.0.0.2 ――配置静态默认路由
R3-jin(config)#router ospf 1
R3-jin(config-router)#default-information originate ――重分发默认路由
R3-jin(config-router)#end
R3-jin#
R3-jin#show ip route
O IA 50.0.0.0/8 [110/65] via 40.0.0.2, 00:00:06, Serial2/0
C 70.0.0.0/8 is directly connected, FastEthernet1/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
O IA 20.0.0.0/8 [110/2] via 30.0.0.2, 00:00:06, FastEthernet0/0
C 40.0.0.0/8 is directly connected, Serial2/0
O IA 10.0.0.0/8 [110/3] via 30.0.0.2, 00:00:06, FastEthernet0/0
O IA 60.0.0.0/8 [110/66] via 40.0.0.2, 00:00:06, Serial2/0
C 30.0.0.0/8 is directly connected, FastEthernet0/0
S* 0.0.0.0/0 [1/0] via 70.0.0.2 ――静态路由
R3-jin#
R1
R1-jin#
R1-jin#show ip route
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
O IA 50.0.0.0/8 [110/67] via 20.0.0.2, 00:02:41, FastEthernet1/0
C 20.0.0.0/8 is directly connected, FastEthernet1/0
O IA 40.0.0.0/8 [110/66] via 20.0.0.2, 00:08:37, FastEthernet1/0
C 10.0.0.0/8 is directly connected, FastEthernet0/0
O IA 60.0.0.0/8 [110/68] via 20.0.0.2, 00:02:42, FastEthernet1/0
O IA 30.0.0.0/8 [110/2] via 20.0.0.2, 00:10:17, FastEthernet1/0
O*E2 0.0.0.0/0 [110/1] via 20.0.0.2, 00:00:10, FastEthernet1/0 ――动态默认动态路由
R1-jin#
R2
R2-jin#
R2-jin#show ip route
O IA 50.0.0.0/8 [110/66] via 30.0.0.1, 00:00:22, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
C 20.0.0.0/8 is directly connected, FastEthernet1/0
O 40.0.0.0/8 [110/65] via 30.0.0.1, 00:00:22, FastEthernet0/0
O 10.0.0.0/8 [110/2] via 20.0.0.1, 00:13:14, FastEthernet1/0
O IA 60.0.0.0/8 [110/67] via 30.0.0.1, 00:00:22, FastEthernet0/0
C 30.0.0.0/8 is directly connected, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 30.0.0.1, 00:00:22, FastEthernet0/0
R2-jin#
R4
R4-jin#
R4-jin#show ip route
C 50.0.0.0/8 is directly connected, FastEthernet0/0
4.0.0.0/32 is subnetted, 1 subnets
C 4.4.4.4 is directly connected, Loopback0
O IA 20.0.0.0/8 [110/66] via 40.0.0.1, 00:00:26, Serial1/0
C 40.0.0.0/8 is directly connected, Serial1/0
O IA 10.0.0.0/8 [110/67] via 40.0.0.1, 00:00:26, Serial1/0
O 60.0.0.0/8 [110/2] via 50.0.0.2, 00:02:53, FastEthernet0/0
O 30.0.0.0/8 [110/65] via 40.0.0.1, 00:00:26, Serial1/0
O*E2 0.0.0.0/0 [110/1] via 40.0.0.1, 00:00:26, Serial1/0
R4-jin#
R5
R5-jin#
R5-jin#show ip route
C 50.0.0.0/8 is directly connected, FastEthernet0/0
O IA 20.0.0.0/8 [110/67] via 50.0.0.1, 00:02:48, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
C 5.5.5.5 is directly connected, Loopback0
O IA 40.0.0.0/8 [110/65] via 50.0.0.1, 00:02:48, FastEthernet0/0
O IA 10.0.0.0/8 [110/68] via 50.0.0.1, 00:02:48, FastEthernet0/0
C 60.0.0.0/8 is directly connected, FastEthernet1/0
O IA 30.0.0.0/8 [110/66] via 50.0.0.1, 00:02:48, FastEthernet0/0
O*E2 0.0.0.0/0 [110/1] via 50.0.0.1, 00:00:26, FastEthernet0/0
R5-jin#
三、配置PC, 实现全网通信
VPCS 1 >
VPCS 1 >show
VPCS 1 >ip 10.0.0.2 10.0.0.1 8
VPCS 1 >2
VPCS 2 >ip 60.0.0.2 60.0.0.1 8
VPCS 2 >3
VPCS 3 >ip 70.0.0.2 70.0.0.1 8
VPCS 3 >show
NAME IP/CIDR GATEWAY LPORT RPORT
PC1 10.0.0.2/8 10.0.0.1 10001 11100
PC2 60.0.0.2/8 60.0.0.1 10002 11510
PC3 70.0.0.2/8 70.0.0.1 10003 11310
PC4 0.0.0.0/0 0.0.0.0 10004 30003
PC5 0.0.0.0/0 0.0.0.0 10005 30004
PC6 0.0.0.0/0 0.0.0.0 10006 30005
PC7 0.0.0.0/0 0.0.0.0 10007 30006
PC8 0.0.0.0/0 0.0.0.0 10008 30007
PC9 0.0.0.0/0 0.0.0.0 10009 30008
VPCS 3 >ping 60.0.0.2
60.0.0.2 icmp_seq=1 timeout
60.0.0.2 icmp_seq=2 time=110.000 ms
60.0.0.2 icmp_seq=3 time=156.000 ms
60.0.0.2 icmp_seq=4 time=157.000 ms
60.0.0.2 icmp_seq=5 time=141.000 ms
VPCS 3 >ping 10.0.0.2
10.0.0.2 icmp_seq=1 timeout
10.0.0.2 icmp_seq=2 time=125.000 ms
10.0.0.2 icmp_seq=3 time=125.000 ms
10.0.0.2 icmp_seq=4 time=125.000 ms
10.0.0.2 icmp_seq=5 time=125.000 ms
VPCS 3 >1
VPCS 1 >ping 60.0.0.2
60.0.0.2 icmp_seq=1 time=187.000 ms
60.0.0.2 icmp_seq=2 time=203.000 ms
60.0.0.2 icmp_seq=3 time=265.000 ms
60.0.0.2 icmp_seq=4 time=157.000 ms
60.0.0.2 icmp_seq=5 time=281.000 ms
VPCS 1 >