分类: 系统运维
2010-12-03 13:14:53
实验目的:
掌握路由重分发
实验拓扑:
两台路由器,连接及IP配置如图所示
实验要求:
在R2上配置将直连和静态路由引入到OSPF协议中
配置步骤如下:
1. 配置IP
2. 在R2上配置静态路由,并查看从R1上学习到的路由
3. 在R2上配置OSPF协议,并将直连和静态路由引入
4. 创在R3上配置OSPF协议,并查看从R2上学习到的路由
5. 再查看R1,R2新学习到的路由
6. ping测试
7. 在R1上配置默认路由,并查看R1,R3的路由
具体操作:
1.配置IP
R1(config)#
R1(config)#int lo0
R1(config-if)#ip add 192.168.0.1 255.255.255.0
R1(config-if)#int s3/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#
R2(config)#
R2(config)#int s3/0
R2(config-if)#ip add 192.168.1.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shut
R2(config-if)#int s3/1
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shut
R2(config-if)#
R3(config)#
R3(config-if)# int lo0
R3(config-if)#ip add 192.168.2.3 255.255.255.0
R3(config)# int s3/1
R3(config-if)#ip add 192.168.3.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#
2.在R2上配置静态路由,并查看从R1上学习到的路由
R2(config)#
R2(config)#ip route 192.168.0.0 255.255.255.0 192.168.1.1
R2(config)#
R2(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
S 192.168.0.0/24 [1/0] via 192.168.1.1
C 192.168.1.0/24 is directly connected, Serial3/0
C 192.168.2.0/24 is directly connected, Serial3/1
3.在R2上配置OSPF协议,并将直连和静态路由引入
R2(config)#router ospf 1
R2(config-router)#net 192.168.2.0 255.255.255.0 area 0
R2(config-router)#redistribute connect
% Only classful networks will be redistributed
R2(config-router)#redistribute static
% Only classful networks will be redistributed
R2(config-router)#exit
R2(config)#
4.在R3上配置OSPF协议,并查看从R2上学习到的路由
R3(config)#
R3(config)#router ospf 1
R3(config-router)#net 192.168.2.0 255.255.255.0 area 0
R3(config-router)#net 192.168.3.0 255.255.255.0 area 0
R3(config-router)#exit
R3(config)#
R3(config)#do sh ip route
…… ……
Gateway of last resort is not set
O E2 192.168.0.0/24 [110/20] via 192.168.2.2, 00:00:04, Serial3/1
O E2 192.168.1.0/24 [110/20] via 192.168.2.2, 00:32:25, Serial3/1
C 192.168.2.0/24 is directly connected, Serial3/1
C 192.168.3.0/24 is directly connected, Loopback0
R3(config)#
5.再查看R1,R2新学习到的路由
R1(config)#
R1(config)#do sh ip route
…… ……
Gateway of last resort is not set
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Serial3/0
R1(config)#
R2(config)#
R2(config)#do sh ip route
…… ……
Gateway of last resort is not set
S 192.168.0.0/24 [1/0] via 192.168.1.1
C 192.168.1.0/24 is directly connected, Serial3/0
C 192.168.2.0/24 is directly connected, Serial3/1
192.168.3.0/32 is subnetted, 1 subnets
O 192.168.3.3 [110/65] via 192.168.2.3, 00:48:53, Serial3/1
R2(config)#
虽然R3学习到了R1,但发现R1并没有学R3,故可以知道,R1与R3之间不能通信,测试如下。
6.ping测试
R1#
R1#ping 192.168.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R1#
R2#
R2#ping 192.168.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/68/144 ms
R2#
R2#ping 192.168.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/60/152 ms
R2#
R3#
R3#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
7.在R1上配置默认路由,并查看路由
R1(config)#
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
R1(config)#
R1(config)#do sh ip route
…… ……
Gateway of last resort is 192.168.1.2 to network 0.0.0.0
C 192.168.0.0/24 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Serial3/0
S* 0.0.0.0/0 [1/0] via 192.168.1.2
R1(config)#
此时三台路由器之间可以想互通信了。
倘若是静态路由,
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.1.2
或者
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.1.2
R3里虽有R1路由,但不能ping通R1
本文出自 “一树清劲” 博客,请务必保留此出处http://sunshyfangtian.blog.51cto.com/1405751/420565