5台路由器和2台pc机
R1路由器的配置
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e0/0
R1(config-if)#ip address 192.168.2.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int e0/1
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#net
R1(config-router)#network 192.168.1.0 0.0.0.255 area 1
R1(config-router)#network 192.168.2.0 0.0.0.255 area 1
R1(config-router)#area 1 stub
R1(config-router)#exit
R1#sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.2.1 YES manual up up
Ethernet0/1 192.168.1.1 YES manual up up
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
R1#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.168.2.2 to network 0.0.0.0
C 192.168.1.0/24 is directly connected, Ethernet0/1
C 192.168.2.0/24 is directly connected, Ethernet0/0
O*IA 0.0.0.0/0 [110/11] via 192.168.2.2, 00:24:11, Ethernet0/0
R1#
R2路由器的配置
R2#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int e0/0
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int e0/1
R2(config-if)#ip address 192.168.3.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#network 192.168.2.0 0.0.0.255 area 1
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
R2(config-router)#exit
R2(config)#router ospf 1
R2(config-router)#area 1 stub no-summary
R2#sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.2.2 YES manual up up
Ethernet0/1 192.168.3.1 YES manual up up
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
R2#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
O IA 192.168.4.0/24 [110/20] via 192.168.3.2, 00:10:48, Ethernet0/1
O E2 192.168.5.0/24 [110/20] via 192.168.3.2, 00:07:52, Ethernet0/1
O E2 192.168.6.0/24 [110/20] via 192.168.3.2, 00:05:34, Ethernet0/1
O 192.168.1.0/24 [110/20] via 192.168.2.1, 00:12:00, Ethernet0/0
C 192.168.2.0/24 is directly connected, Ethernet0/0
C 192.168.3.0/24 is directly connected, Ethernet0/1
R2#
R3路由器的配置
R3#
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int e0/0
R3(config-if)#ip address 192.168.3.2 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int e0/1
R3(config-if)#ip address 192.168.4.1 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#router ospf 1
R3(config-router)#network 192.168.3.0 0.0.0.255 area 0
R3(config-router)#network 192.168.4.0 0.0.0.255 area 2
R3(config-router)#area 2 nssa
R3(config-router)#exit
R3(config)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.3.2 YES manual up up
Ethernet0/1 192.168.4.1 YES manual up up
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
R3(config)#do 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
C 192.168.4.0/24 is directly connected, Ethernet0/1
O N2 192.168.5.0/24 [110/20] via 192.168.4.2, 00:11:57, Ethernet0/1
O N2 192.168.6.0/24 [110/20] via 192.168.4.2, 00:09:38, Ethernet0/1
O IA 192.168.1.0/24 [110/30] via 192.168.3.1, 00:11:57, Ethernet0/0
O IA 192.168.2.0/24 [110/20] via 192.168.3.1, 00:11:57, Ethernet0/0
C 192.168.3.0/24 is directly connected, Ethernet0/0
R4路由器的配置
R4#
R4#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int e0/0
R4(config-if)#ip address 192.168.4.2 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int e0/1
R4(config-if)#ip address 192.168.5.1 255.255.255.0
R4(config-if)#no sh
R4(config-if)#exit
R4(config)#router ospf 1
R4(config-router)#network 192.168.4.0 0.0.0.255 area 2
R4(config-router)#area 2 nssa
R4(config-router)#exit
R4(config)#router rip
R4(config-router)#network 192.168.5.0
R4(config-router)#version 2
R4(config-router)#no auto-summary
R4(config-router)#exit
R4(config)#router ospf 1
R4(config-router)#redistribute rip subnets
R4(config-router)#router rip
R4(config-router)#redistribute ospf 1 metric 1
R4(config-router)#exit
R4(config)#do 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
C 192.168.4.0/24 is directly connected, Ethernet0/0
C 192.168.5.0/24 is directly connected, Ethernet0/1
R 192.168.6.0/24 [120/1] via 192.168.5.2, 00:00:06, Ethernet0/1
O IA 192.168.1.0/24 [110/40] via 192.168.4.1, 00:02:26, Ethernet0/0
O IA 192.168.2.0/24 [110/30] via 192.168.4.1, 00:02:26, Ethernet0/0
O IA 192.168.3.0/24 [110/20] via 192.168.4.1, 00:02:26, Ethernet0/0
R4(config)#do sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.4.2 YES manual up up
Ethernet0/1 192.168.5.1 YES manual up up
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
R4(config)#
R5路由器的配置
R5#
R5#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R5(config)#int e0/0
R5(config-if)#ip address 192.168.5.2 255.255.255.0
R5(config-if)#no sh
R5(config-if)#int e0/1
R5(config-if)#ip address 192.168.6.1 255.255.255.0
R5(config-if)#no sh
R5(config-if)#exit
R5(config)#router rip
R5(config-router)#network 192.168.5.0
R5(config-router)#network 192.168.6.0
R5(config-router)#version 2
R5(config-router)#no auto-summary
R5(config-router)#exit
R5#sh ip int br
Interface IP-Address OK? Method Status Protocol
Ethernet0/0 192.168.5.2 YES manual up up
Ethernet0/1 192.168.6.1 YES manual up up
Ethernet0/2 unassigned YES unset administratively down down
Ethernet0/3 unassigned YES unset administratively down down
R5#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
R 192.168.4.0/24 [120/1] via 192.168.5.1, 00:00:20, Ethernet0/0
C 192.168.5.0/24 is directly connected, Ethernet0/0
C 192.168.6.0/24 is directly connected, Ethernet0/1
R 192.168.1.0/24 [120/1] via 192.168.5.1, 00:00:20, Ethernet0/0
R 192.168.2.0/24 [120/1] via 192.168.5.1, 00:00:20, Ethernet0/0
R 192.168.3.0/24 [120/1] via 192.168.5.1, 00:00:20, Ethernet0/0
R5#
最后可以用show查看各个路由器的信息
show ip route //查看路由表
show ip ospf //查看OSPF的配置
show ip int ospf int e0/0 // 查看OSPF接口的数据结构
show ip route os //查看学习到的路由
验证PC机的连通性