一、拓扑图:
二、配置说明与分析:
1、按照拓扑图配置各路由器的
IP地址和协议,并在
R2和
R5上做重分发,保证所有的链路的连通性。看一下
R2上的重分发配置:
R2#show run
router ospf 1
log-adjacency-changes
redistribute rip metric 200 subnets (把
RIP发进
OSPF过来的
cost 我定义为
200)
network 172.16.255.0 0.0.0.3 area 0
!
router rip
redistribute ospf 1 metric 11 (把
ospf 发进
RIP过来的
cost 我定义为
11)
network 192.168.1.0
|
2、那么应该说通过
R2这个路由后:
ospf 区域到
rip区域后
cost 将会为成为我们定义的值
11
Rip区域到
ospf 区域后
cost 将会成为我们定义的值
200
3、在
RIP区域看一下
ospf 区域过来的路由:
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 not set
R
172.16.0.0/16 [120/11] via 192.168.1.2, 00:00:07, Serial1/1(ospf那边过来的
,RIP把它当
R)
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Loopback0
C 192.168.1.0/24 is directly connected, Serial1/1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
|
4、在
OSPF区域看一下
RIP区域过来的路由:
R3#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
172.16.0.0/30 is subnetted, 3 subnets
C 172.16.255.0 is directly connected, Serial1/0
C 172.16.255.4 is directly connected, Serial1/1
O 172.16.255.8 [110/128] via 172.16.255.6, 00:49:26, Serial1/1
O E2 10.0.0.0/8 [110/200] via 172.16.255.1, 00:49:26, Serial1/0
O E2 192.168.1.0/24 [110/200] via 172.16.255.1, 00:49:26, Serial1/0
(通过
R2过来的定义了
200)
O E1 192.168.2.0/24 [110/328] via 172.16.255.6, 00:49:26, Serial1/1
(通过
R5过来的,那么为什么是
328呢?这条路由经过
R5过来的,它会以
R5上的重分发的
cost值计算,因为我在
R5重发布的时候做了
redistribute rip metric 200 metric-type 1 subnets 这样就会叠加经过
ospf 区域的
cost
:RIP
à
OSPF (cost 200) + R4―>R5 (cost 64) + R3―>R4 (cost 64) = cost 328)
|
5、通过上面的图示我们弄清了
rip和
ospf 区域的
cost值之后
,现在我们在
R5上看一下路由表
:
R5#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
172.16.0.0/30 is subnetted, 3 subnets
O 172.16.255.0 [110/192] via 172.16.255.9, 00:03:00, Serial1/0
O 172.16.255.4 [110/128] via 172.16.255.9, 00:03:00, Serial1/0
C 172.16.255.8 is directly connected, Serial1/0
O E2 10.0.0.0/8 [110/200] via 172.16.255.9, 00:02:59, Serial1/0
(居然绕了
4个路由器
)
O E2 192.168.1.0/24 [110/200] via 172.16.255.9, 00:02:59, Serial1/0
(也绕远了
,不直接通过
R1走
)
C 192.168.2.0/24 is directly connected, FastEthernet0/0
R5#
|
6、我们看到
R5到
10.0.0.0/8和
192.168.1.0/24都是绕了个大圈通过
ospf 区域来走,那它为什么不直接通过
R1这一跳来走呢。这样路径更近,只要通过
R1一个路由器转发就行啊。呵呵!这是因为
R5认为
R2重分发过进来路由的管理距离是
110。
rip是
120,走
ospf更短。所以不选择
R1走,而是走
R4。看来管理距离决定着路由器选择那个路由协议的路径过去。所以在这种情况之后。我们要去手动地在
R5上修改到达
R1的管理距离,强制让它选择最佳路由走
R1。
7、我们可以通过一个
acl加指定链路的
distance来做:
R5(config)#access-list 1 permit 10.0.0.0 0.255.255.255(
建立一个对目的网络的访问控制列表)
R5(config)#router rip
R5(config-router)#distance 85 192.168.2.0 0.0.0.255 1(
定义到R1的管理距离为85匹配access-list1)
|
8、我们来看一下
access-list 1:
R5#show access-lists 1
Standard IP access list 1
10
ermit 10.0.0.0, wildcard bits 0.255.255.255 (1 match) 已经有
1个匹配了
|
9、看一下
R5 的路由表:
R5#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
172.16.0.0/30 is subnetted, 3 subnets
O 172.16.255.0 [110/192] via 172.16.255.9, 02:32:03, Serial1/0
O 172.16.255.4 [110/128] via 172.16.255.9, 02:32:03, Serial1/0
C 172.16.255.8 is directly connected, Serial1/0
R
10.0.0.0/8 [85/1] via 192.168.2.1, 00:00:11, FastEthernet0/0 (
现在变成R了,并且走R1了
)
O E2 192.168.1.0/24 [110/200] via 172.16.255.9, 00:09:57, Serial1/0(
这条路径加一条ACL就能改到走R1了,那样将会变成R不会是O E2
)
C 192.168.2.0/24 is directly connected, FastEthernet0/0
|
10、通过以上的方法,我们可以通过改某一个链路的管理距离让它走最佳的网络到达目的地。同时为了链路的稳定和使
R2到这一网段也走
R1,我们也应该在
R2上做相同的操作,先看一下没改之前的
route:
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
172.16.0.0/30 is subnetted, 3 subnets
C 172.16.255.0 is directly connected, Serial1/1
O 172.16.255.4 [110/128] via 172.16.255.2, 02:46:52, Serial1/1
O 172.16.255.8 [110/192] via 172.16.255.2, 02:46:52, Serial1/1
O E1 10.0.0.0/8 [110/392] via 172.16.255.2, 00:15:01, Serial1/1
C 192.168.1.0/24 is directly connected, Serial1/0
O E1 192.168.2.0/24 [110/392] via 172.16.255.2, 02:46:52, Serial1/1
R2#
|
11、这次我来把两条都改掉管理距离让它们走
R1:
R2(config)#access-list 1 permit 10.0.0.0 0.0.0.255 (建立第
一个到目的网络的访问控制列表
)
R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255(建立第二
个到目的网络的访问控制列表
)
R2(config)#router rip
R2(config-router)#distance 85 192.168.1.1 0.0.0.0 1 (设定到
R1的管理距离
)
|
12、再来看一下
R2的
route:
R2(config-router)#do sho 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
172.16.0.0/30 is subnetted, 3 subnets
C 172.16.255.0 is directly connected, Serial1/1
O 172.16.255.4 [110/128] via 172.16.255.2, 04:12:19, Serial1/1
O 172.16.255.8 [110/192] via 172.16.255.2, 04:12:19, Serial1/1
R 10.0.0.0/8 [85/1] via 192.168.1.1, 00:00:18, Serial1/0
C 192.168.1.0/24 is directly connected, Serial1/0
R 192.168.2.0/24 [85/1] via 192.168.1.1, 00:00:18, Serial1/0
|
两条都变成
R了,都通过
R1到目的网段。不会走ospf网络。
本文出自 “ 超越技术成就价值” 博客,请务必保留此出处 http://supercisco.blog.51cto.com/672109/251983
本文出自 51CTO.COM技术博客
|