Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3048967
  • 博文数量: 131
  • 博客积分: 10013
  • 博客等级: 上将
  • 技术积分: 2375
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-21 02:01
文章存档

2013年(4)

2010年(18)

2009年(61)

2008年(48)

我的朋友

分类: WINDOWS

2010-05-23 22:22:08

    有的人理解了当两种路由协议(比如OSPF和BGP)跑在同一个网络里时,通常情况下会进行路由重分发,即将各自的学习到的路由注入到彼此的路由协议进程里。有人就不理解为什么进行静态路由和直连路由重分发?原理其实一模一样,理解起来不难:因为静态路由也是路由协议的一种,对吗?如果不进行静态路由的重分发,那么将大大增加了网络工程师的工作量。下面我通过PT5.2实验来验证。
 
(图一:全局拓扑图)

 

(图二:云图)

下面是本次试验的PKT文件:
文件: ospfredistributeconnected&static-1.rar
大小: 7KB
下载: 下载
 
Router4配置文件:
Router#sh run
hostname Router
!
interface FastEthernet0/0
 ip address 172.16.1.2 255.255.255.0
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 135.136.137.193 255.255.255.192
 duplex auto
 speed auto
ip classless
ip route 0.0.0.0 0.0.0.0 172.16.1.1
!

end
Router# 
Router0配置文件:
R1#sh run
!
hostname R1
!
no ip domain-lookup
interface FastEthernet0/0
 ip address 10.10.10.1 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 172.16.1.1 255.255.255.0
 duplex auto
 speed auto
!
router ospf 50
 log-adjacency-changes
 redistribute static subnets
 network 10.10.10.0 0.0.0.3 area 0
!
ip classless
ip route 10.10.10.8 255.255.255.252 10.10.10.2
ip route 135.136.137.192 255.255.255.192 172.16.1.2
!
end

R1#
Router1配置文件:
R2#sh run  
!
hostname R2
!
interface FastEthernet0/0
 ip address 10.10.10.2 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.10.10.5 255.255.255.252
 duplex auto
 speed auto
!
router ospf 100
 log-adjacency-changes
 network 10.10.10.4 0.0.0.3 area 0
 network 10.10.10.0 0.0.0.3 area 0
!
ip classless
!
line con 0
line vty 0 4
 login
!
!
!
end
Router2配置文件:
R2#
R3#sh run
hostname R3
!
interface FastEthernet0/0
 ip address 10.10.10.6 255.255.255.252
 duplex auto
 speed auto
!
interface FastEthernet0/1
 ip address 10.10.10.9 255.255.255.252
 duplex auto
 speed auto
!
router ospf 200
 log-adjacency-changes
 network 10.10.10.4 0.0.0.3 area 0
 network 10.10.10.8 0.0.0.3 area 0
!
ip classless
line con 0
line vty 0 4
 login
!
!
!
end
Router3配置文件:
R3#
R4#sh run
!
hostname R4
!interface FastEthernet0/0
 ip address 10.10.10.10 255.255.255.252
 duplex auto
 speed auto
!
router ospf 300
 log-adjacency-changes
 network 10.10.10.8 0.0.0.3 area 0
!
ip classless
ip route 10.10.10.0 255.255.255.252 10.10.10.9
end

R4# 
实验一:静态路由重分发
    注意到Router0跑了两种路由协议:OSPF和静态路由,一开始我没有在该路由器上开ospf路由进程,结果怎么配置静态路由协议都不通,最后才发现,没有开启OSPF路由进程就无法和Router1路由器的OSPF进程形成邻接关系,当然Router3、Router2路由器就无法学习到了。
    因为Router4路由器位于接入层,我们不想让它跑OSPF协议,做个默认路由即可,又要和其他网络都联通,而且又不想再所有OSPF网络路由器一一配置到新增的这个网络的静态路由,怎么做呢?当然是在Router0上实施静态路由重分发了,即Router0路由器将到达135.136.137.192/26这个网络的静态路由都重分发到区域0的所有OSPF路由器中。
    命令是:
                 router ospf 50
                 redistribute static subnets 
然后我们就可以在跑ospf的路由器Router1、Router2和Router3上看到如下路由:
Router#sh ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
     10.0.0.0/30 is subnetted, 3 subnets
C       10.10.10.0 is directly connected, FastEthernet0/0
C       10.10.10.4 is directly connected, FastEthernet0/1
O       10.10.10.8 [110/2] via 10.10.10.6, 01:24:13, FastEthernet0/1
     135.136.0.0/26 is subnetted, 1 subnets
O E2    135.136.137.192 [110/20] via 10.10.10.1, 01:05:02, FastEthernet0/0
 
 
实验二:直连路由重分发
    还有一种情况,如果Router0路由器以后再加入了新的网络,那么是不是要管理员一条条宣告ospf直连路由呢?当然可以,但不是最好的办法;使用直连路由的重分发即可实现加入新网络后,OSPF路由器可以“自动地”宣告这条新增路由,使用直连路由重分发!
在Router0路由器上新增5个网络:
!
interface Loopback1
 ip address 192.168.1.1 255.255.255.0
!
interface Loopback2
 ip address 192.168.2.1 255.255.255.0
!
interface Loopback3
 ip address 192.168.3.1 255.255.255.0
!
interface Loopback4
 ip address 192.168.4.1 255.255.255.0
!
interface Loopback5
 ip address 192.168.5.1 255.255.255.0
!
一般情况下,我们要在OSPF进程里一一宣告路由才能让其他路由学习到这5个网络,现在我们在Router上实施直连路由重分布
        R1(config)#router os 50
        R1(config-router)#redistribute connected subnets
现在我们看下Router3路由器的路由表:
R4#sh ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
       i - IS-IS, 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
     10.0.0.0/30 is subnetted, 3 subnets
S       10.10.10.0 [1/0] via 10.10.10.9
O       10.10.10.4 [110/2] via 10.10.10.9, 01:38:15, FastEthernet0/0
C       10.10.10.8 is directly connected, FastEthernet0/0
     135.136.0.0/26 is subnetted, 1 subnets
O E2    135.136.137.192 [110/20] via 10.10.10.9, 01:19:04, FastEthernet0/0
     172.16.0.0/24 is subnetted, 1 subnets
O E2    172.16.1.0 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
O E2 192.168.1.0/24 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
O E2 192.168.2.0/24 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
O E2 192.168.3.0/24 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
O E2 192.168.4.0/24 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
O E2 192.168.5.0/24 [110/20] via 10.10.10.9, 00:00:10, FastEthernet0/0
 
    通常在企业或运营商网络中,我们会很频繁地使用静态路由和直连路由的重分发。理解它才是最重要的。
 
阅读(26591) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~