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域中傳遞默認路由的幾種方法。希望還能找到其它方法

注:源於工大瑞普

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