RIP传递默认路由的5种方法

 

 

 

 

本文转载自http://hi.baidu.com/zefamail/item/1a142f0ee82a1b38f2eafc2c 。

看卷一的路由重分配,对rip默认路由认识不够,在网上找到好文一篇,共享

在一个单出口网络内启用RIP协议,在网络出口处的路由器需要向RIP域内传播一条默认路由,这样,域内的路由器就可以通过默认路由访问外部网络。下面我们就用试验来模拟这个环境。到目前为止;通过RIP传递默认路由共有5种方法。
1 default-information
2
 手工写一条默认路由(到NULL0 然后重分布到RIP
3
 手工写一条默认路由(到NULL0 在进程中宣告
4 ip default-network
5
 在接口汇总 0.0.0.0/0 NULL0的路由
***************************************************************************************************************
 路由器基本配置
R1

interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Serial1/0
ip address 12.0.0.1 255.255.255.0

router rip
version 2
network 1.0.0.0
network 12.0.0.0
no auto-summary
------------------
R2
interface Serial1/0
ip address 12.0.0.2 255.255.255.0
interface Serial1/1
ip address 23.0.0.2 255.255.255.0
router rip
version 2
network 2.0.0.0
network 12.0.0.0
no auto-summary
------------------
R3
interface Serial1/0
ip address 23.0.0.3 255.255.255.0
**************************************************************************************************************

二 方法1 default-information
r2#sh run | b r r
router rip
version 2
network 2.0.0.0
network 12.0.0.0
default-information originate
no auto-summary
r1#sh ip rou

1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:09, Serial1/0 /可以看到这时在R1上产生了一条默认路由
r1#ping 23.0.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 23.0.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/41/68 ms
----------------------------------------
此外,在default-information originate可以调用一个route-map来匹配一个接口或路由,当这个路由有效的时候才会传递默认路由。
首先我们在R2上建立一个loopback接口,并将它宣告到RIP中,然后用ACL来匹配这个接口,建立route-map调用这个ACL,最后在 default-information originate
命令后调用这个route-map
R2
access-list 1 permit 2.2.2.2

route-map WY permit 10
match ip address 1

r2#sh run | b r r
router rip
version 2
network 2.0.0.0
network 12.0.0.0
default-information originate route-map WY
no auto-summary
r1#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
R 2.2.2.2 [120/1] via 12.0.0.2, 00:00:02, Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:02, Serial1/0 /这时R2向R1传递了一条默认路由
r2(config)#int lo0
r2(config-if)#shutdown /
这时我们将loopback接口关闭
r1#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
这时,R2不向R1传递默认路由,因为loopback接口关闭,ACL失效,route-map失效,所以 default-information originate命令不执行
-----------------------------------------
下面我们在R2,R3之间启用EIGRP,在R3上起一个loopback接口,并宣告到EIGRP中,这时R2可以学习到3.3.3.0,在R2上建立ACL匹配从R3学习到的这条路由,随后建立route-map并调用ACL,同样最后在R2的RIP进程中的default-information originate命令后面调用这个route-map。
r2#sh run | b r e
router eigrp 90
network 23.0.0.0 0.0.0.255
no auto-summary

r3#sh run | b r e
router eigrp 90
network 3.3.3.0 0.0.0.255
network 23.0.0.0 0.0.0.255
no auto-summary

r2#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 12.0.0.1, 00:00:05, Serial1/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 23.0.0.3, 00:01:42, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0


R2
access-list 1 permit 3.3.3.0 0.0.0.255

route-map WY permit 10
match ip address 1

R2
router rip
version 2
network 12.0.0.0
default-information originate
 route-map WY
no auto-summary

r1#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:01, Serial1/0 /这时R2向R1传递一条默认路由
r3(config)#int lo0
r3(config-if)#shutdown /
在R3上关闭这个loopback接口
r1#sh ip rou

1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0 

R2不再向R1传递默认路由,同样因为loopback接口失效,导致 default-information originate命令不执行
-----------------------------------------
方法2 手工写一条默认路由(到NULL0)然后重分布到RIP中
r2(config)#ip route 0.0.0.0 0.0.0.0 null 0 /在R2上建立一条默认路由

r2(config-router)#redistribute static /重分布静态路由到RIP中
r1#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:02, Serial1/0 /这时,R2向R1传递一条默认路由
-----------------------------------------
方法3 手工写一条默认路由(到NULL0)在进程中宣告

r2(config)#ip route 0.0.0.0 0.0.0.0 null 0

r2#sh run | b r r
router rip
version 2
network 12.0.0.0
network 0.0.0.0 /将这条默认路由宣告到R2的RIP进程中
no auto-summary

r1#sh ip rou
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:07, Serial1/0 /R2向R1传递默认路由
-----------------------------------------
方法4 ip default-network
r2(config)#ip default-network 23.0.0.0 /建立一个缺省网络
r1#sh ip rou

1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:09, Serial1/0 /R2向R1传递默认路由
-----------------------------------------
方法5 在接口汇总 0.0.0.0/0 到NULL0的路由

r2(config)#ip route 0.0.0.0 0.0.0.0 null 0 /先建立一条默认路由

r2#sh run int s1/0

interface Serial1/0
ip address 12.0.0.2 255.255.255.0
ip summary-address rip 0.0.0.0 0.0.0.0 /在接口上手工汇总这条默认路由

r1#sh ip rou

1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 12.0.0.2, 00:00:09, Serial1/0 /R2向R1传递默认路由
通过本次试验,我们了解了几种向RIP域中传递默认路由的几种方法。希望还能找到其它方法

注:源于工大瑞普

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章