本文歡迎轉(zhuǎn)載,轉(zhuǎn)載請(qǐng)注明出處和作者。
不同的路由協(xié)議,是不會(huì)交換路由條目的,因?yàn)槔鏞SPF與EIGRP,不來就不在一個(gè)組播組在傳播路由更新,相當(dāng)于兩個(gè)獨(dú)立的微信群在聊天,誰也不搭理誰。
但是,總有需要讓他們通信,否則網(wǎng)絡(luò)之間就不通了,這個(gè)時(shí)候就要采用路由重分布(又叫路由重分發(fā))的技術(shù)了。
拓?fù)淙缦拢?/strong>

1、預(yù)配置
R1:
en
conf t
host R1
int lo 0
ip add 1.1.1.1 255.255.255.0
no shut
int se2/0
ip add 12.1.1.1 255.255.255.0
clock rate 64000
no shut
int se3/0
ip add 13.1.1.1 255.255.255.0
clo rate 64000
no shut
R2:
en
conf t
host R2
int lo 0
ip add 2.2.2.2 255.255.255.0
no shut
int se2/0
ip add 12.1.1.2 255.255.255.0
no shut
int se3/0
ip add 24.1.1.2 255.255.255.0
clock rate 64000
no shut
R3:
en
conf t
host R3
int lo 0
ip add 3.3.3.3 255.255.255.0
no shut
int se2/0
ip add 13.1.1.3 255.255.255.0
no shut
int se3/0
ip add 34.1.1.3 255.255.255.0
clock rate 64000
no shut
R4:
en
conf t
host R4
int lo 0
ip add 4.4.4.4 255.255.255.0
no shut
int se2/0
ip add 24.1.1.4 255.255.255.0
no shut
int se3/0
ip add 34.1.1.4 255.255.255.0
no shut
int fa0/0
ip add 192.168.1.254 255.255.255.0
no shut
2、配置單邊的OSPF
先配置R1到R2到R4的OSPF
怎么做呢,就是啟用OSPF進(jìn)程,然后宣告的時(shí)候,注意只把這邊的網(wǎng)段宣告進(jìn)去就好
例如R1,只宣告1.1.1.0/24與12.1.1.0/24,不要宣告13.1.1.0/24進(jìn)去OSPF進(jìn)程即可。
R1:
router ospf 1
network 1.1.1.0 0.0.0.255 area 0
network 12.1.1.0 0.0.0.255 area 0
R2:
router ospf 1
network 2.2.2.0 0.0.0.255 area 0
network 12.1.1.0 0.0.0.255 area 0
network 24.1.1.0 0.0.0.255 area 0
R4:
router ospf 1
network 4.4.4.0 0.0.0.255 area 0
network 24.1.1.0 0.0.0.255 area 0
network 192.168.1.0 0.0.0.255 area 0
在R2上面show ip route
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.1.1.1, 00:40:17, Serial2/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/65] via 24.1.1.4, 00:40:17, Serial3/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial2/0
24.0.0.0/24 is subnetted, 1 subnets
C 24.1.1.0 is directly connected, Serial3/0
3、配置單邊的EIGRP鏈路
再配置R1到R3到R4的EIGRP,原理同上,啟用EIGRP進(jìn)程,增加宣告需要的網(wǎng)段。
*注意,R4不要把4.4.4.0/24與192.168.1.0/24 宣告進(jìn)eigrp。
R1:
router eigrp 1
no auto-summary
network 1.1.1.0 0.0.0.255
network 13.1.1.0 0.0.0.255
R3:
router eigrp 1
no auto-summary
network 3.3.3.0 0.0.0.255
network 13.1.1.0 0.0.0.255
network 34.1.1.0 0.0.0.255
R4:
router eigrp 1
no auto-summary
network 34.1.1.0 0.0.0.255
重新到R2 show ip route,發(fā)現(xiàn)R2是沒有任何路由條目的變化的,可以再到R1上面去show ip route,能夠看到R1既有EIGRP也有OSPF的路由條目。
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.1.1.1, 00:40:17, Serial2/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/65] via 24.1.1.4, 00:40:17, Serial3/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial2/0
24.0.0.0/24 is subnetted, 1 subnets
C 24.1.1.0 is directly connected, Serial3/0
因?yàn)?,R1既開啟了eigrp進(jìn)程,也開了ospf進(jìn)程,而R2根本沒有,只跑了OSPF進(jìn)程。所以EIGRP的路由是不會(huì)傳遞到給R2的。
那么如果R2想與R3通信,怎么辦呢。
這個(gè)時(shí)候就要使用路由重分布技術(shù)了。可以將eigrp路由重分布進(jìn)入ospf,也可以將ospf路由重分布進(jìn)入eigrp。
例如,我們想要R2里面能獲得去往R3的路由,可以在R1(ospf與eigrp的邊界)上面,將eigrp重分布到ospf里面。
R1:
router ospf 1
redistribute eigrp 1 subnets
然后在R2上面show ip route
Gateway of last resort is not set
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.1.1.1, 00:44:06, Serial2/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
O E2 3.3.3.0 [110/20] via 12.1.1.1, 00:00:08, Serial2/0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/65] via 24.1.1.4, 00:44:06, Serial3/0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial2/0
13.0.0.0/24 is subnetted, 1 subnets
O E2 13.1.1.0 [110/20] via 12.1.1.1, 00:00:08, Serial2/0
24.0.0.0/24 is subnetted, 1 subnets
C 24.1.1.0 is directly connected, Serial3/0
34.0.0.0/24 is subnetted, 1 subnets
O E2 34.1.1.0 [110/20] via 12.1.1.1, 00:00:08, Serial2/0
會(huì)看到出現(xiàn)了O E2的ospf路由,這種就是從其他路由協(xié)議重分布進(jìn)來ospf的路由,還有另外一種叫O E1的。
OE1與OE2的區(qū)別是,OE2是默認(rèn)的,總是將重分布進(jìn)來的路由,metric取20。而OE1則會(huì)除了20外,還會(huì)累加上OSPF區(qū)域內(nèi)的COST(開銷)
此時(shí),R2可以ping通3.3.3.3嗎?答案是不可以。
因?yàn)镽2已經(jīng)有了到3.3.3.3的路由,但是R3那邊卻沒有到2.2.2.2的路由,因?yàn)槲覀冎话裡igrp的路由重分布進(jìn)入ospf,但是eigrp里面卻沒有ospf的路由。
再在R1上面,將ospf重分布進(jìn)入eigrp。
router eigrp 1
redistribute ospf 1 metric 1000 100 255 1 1500
其中,metric依次為帶寬,時(shí)延,可靠性,負(fù)載,最大傳輸單元。
在R3上面show ip route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
D 1.1.1.0 [90/20640000] via 13.1.1.1, 00:10:15, Serial2/0
2.0.0.0/32 is subnetted, 1 subnets
D EX 2.2.2.2 [170/20537600] via 13.1.1.1, 00:00:20, Serial2/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
D EX 4.4.4.4 [170/20537600] via 13.1.1.1, 00:00:20, Serial2/0
12.0.0.0/24 is subnetted, 1 subnets
D EX 12.1.1.0 [170/20537600] via 13.1.1.1, 00:00:21, Serial2/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial2/0
24.0.0.0/24 is subnetted, 1 subnets
D EX 24.1.1.0 [170/20537600] via 13.1.1.1, 00:00:20, Serial2/0
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Serial3/0
現(xiàn)在再在R2重新ping R3,發(fā)現(xiàn)網(wǎng)絡(luò)可達(dá)了。