自己制作二維碼的軟件seo服務(wù)公司招聘
一、知識補(bǔ)充
1、ABR和ASBR
1.1 ABR
ABR指的是邊界路由,通常位于兩個(gè)或多個(gè)區(qū)域之間,用于在不同的OSPF區(qū)域之間傳遞信息。當(dāng)一個(gè)路由器同時(shí)連接到兩個(gè)或多個(gè)區(qū)域時(shí),它就成為了ABR,它需要維護(hù)每個(gè)區(qū)域的拓?fù)湫畔⒑吐酚杀?#xff0c;并在不同區(qū)域之間進(jìn)行信息傳遞和路由交換。
1.2 ASBR
ASBR是指自治系統(tǒng)邊界路由器,它是連接不同自治系統(tǒng)之間的路由器,用于在不同的自治系統(tǒng)之間傳遞路由信息。當(dāng)一個(gè)路由器連接到不同的自治系統(tǒng)時(shí),它就成為了ASBR,它需要維護(hù)每個(gè)自治系統(tǒng)的拓?fù)湫畔⒑吐酚杀?#xff0c;并在不同自治系統(tǒng)之間進(jìn)行信息傳遞和路由交換。
2、路由匯總
2.1 介紹
- 路由匯總( Route Aggregation ),又稱路由聚合(Route Summarization),指的是把一組明細(xì)路由匯聚成一條匯總路由條目的操作
- 路由匯總能夠減少路由條目數(shù)量、減小路由表規(guī)模,從而減輕路由器的資源消耗
- RIP、BGP等協(xié)議支持自動(dòng)或者手工路由匯總,但OSPF僅支持手工路由匯總
- OSPF支持兩種匯總:
- 部署在ABR上,域間路由匯總
- 部署在ASBR上,域外路由匯總
域內(nèi)路由匯總
router ospf 1
area 2 range x.x.x.x y.y.y.y cost *
// x.x.x.x 匯總后的網(wǎng)段
// y.y.y.y 匯總后的子網(wǎng)掩碼{非反掩碼}
域外路由匯總
router ospf 1
summary-address x.x.x.x y.y.y.y
// x.x.x.x 匯總后的網(wǎng)段
// y.y.y.y 匯總后的子網(wǎng)掩碼{非反掩碼}
2.2匯總路由的計(jì)算
2.2.1例1 計(jì)算下述題目中的路由
loopback1-loopback6
lo1:10.1.1.1/24
lo2:10.1.2.1/24
lo3:10.1.3.1/24
lo4:10.1.4.1/24
lo5:10.1.5.1/24
lo6:10.1.6.1/24
1、首先將這6個(gè)IP地址轉(zhuǎn)換為二進(jìn)制,分別對齊排列,觀察二進(jìn)制地址。
2、可以發(fā)現(xiàn),前21位二進(jìn)制數(shù)都一致,由此可以可以得出,前21位二進(jìn)制數(shù)作網(wǎng)絡(luò)位,剩余位數(shù)作主機(jī)位。
3、將主機(jī)位全部置為0,得出的二進(jìn)制數(shù)轉(zhuǎn)換為十進(jìn)制,就得網(wǎng)絡(luò)地址,一共有21個(gè)網(wǎng)絡(luò)位,也就是掩碼的簡寫為21位。
4、由此我們可以得出,匯總路由為10.1.0.0/21
例2 計(jì)算R2上的匯總路由
loopback1-loopback6
lo1:10.1.11.1/24
lo2:10.1.12.1/24
lo3:10.1.13.1/24
lo4:10.1.14.1/24
lo5:10.1.15.1/24
lo6:10.1.16.1/24
1、有一個(gè)技巧,我們只需要取地址區(qū)間的首尾兩個(gè)地址作運(yùn)算即可?!具@里取10.1.11.1/24 10.1.16.1/24】
2、可以發(fā)現(xiàn)前面19位數(shù)一致,前19位作網(wǎng)絡(luò)位,剩余位數(shù)作主機(jī)位。
3、將主機(jī)位全部置為0,轉(zhuǎn)換為十進(jìn)制,得出網(wǎng)絡(luò)地址;相同位數(shù)即為子網(wǎng)掩碼的縮寫
4、得出匯總路由為10.1.0.0/19
3、ospf區(qū)域認(rèn)證
- 加密方式分為明文認(rèn)證和加密認(rèn)證
- 明文認(rèn)證:密碼在報(bào)文中可見
- 密文認(rèn)證:密碼在報(bào)文中不可見
- 驗(yàn)證方式分為接口認(rèn)證、區(qū)域認(rèn)證和虛鏈路認(rèn)證
- 接口認(rèn)證:僅針對一條鏈路上進(jìn)行驗(yàn)證
- 區(qū)域認(rèn)證:將路由器上屬于某個(gè)特定區(qū)域的接口全部都激活相應(yīng)的驗(yàn)證方式
- 虛鏈路認(rèn)證:針對虛鏈路進(jìn)行認(rèn)證
接口認(rèn)證–明文
int g0/0
ip ospf authentication // 為該接口開啟明文認(rèn)證
ip ospf message-digest-key ruijie // 接口下配置明文密鑰“ruijie”
exit
接口認(rèn)證–密文
int g0/0
ip ospf authentication message-digest // 為該接口開啟加密認(rèn)證
ip ospf message-digest-key 1 md5 ruijie // 接口下開啟md5密鑰“ruijie”
exit
區(qū)域認(rèn)證–明文
router ospf 1
area 0 authentication // 在ospf進(jìn)程1的骨干區(qū)域開啟區(qū)域認(rèn)證
exit
int g0/0
ip ospf authentication-key ruijie // 在所有屬于骨干區(qū)域的接口下配置明文密鑰"ruijie"
exit
區(qū)域認(rèn)證–密文
router ospf 1
area 0 authentication message-digest // 在ospf進(jìn)程1的骨干區(qū)域中開啟區(qū)域認(rèn)證
exit
int g0/0
ip ospf message-digest-key 1 md5 ruijie // 接口下開啟md5密鑰“ruijie”
exit
虛鏈路認(rèn)證–明文
router ospf 1
area 0 virtual-link x.x.x.x authentication // 開啟明文認(rèn)證
area 0 virtual-link x.x.x.x authentication-key ruijie // 配置md5密鑰
exit
虛鏈路認(rèn)證–密文
router ospf 1
area 0 virtual-link x.x.x.x authentication message-digest // 開啟明文認(rèn)證
area 0 virtual-link x.x.x.x authentication-key 1 md5 ruijie // 配置md5密鑰
exit
4、路由選路
OSPF協(xié)議中的"cost"值是指路由器到達(dá)目的地的開銷,也可以理解為路徑的代價(jià)。在OSPF協(xié)議中,每條鏈路都會(huì)被分配一個(gè)開銷值,這個(gè)開銷值取決于鏈路的帶寬。一般來說,帶寬越大,開銷值就越小,表示該鏈路的優(yōu)先級更高,路由器更傾向于通過這樣的鏈路進(jìn)行數(shù)據(jù)傳輸。開銷值越小則越優(yōu)先。
在標(biāo)準(zhǔn)的RFC2328中規(guī)定了不同速率鏈路的默認(rèn)開銷值,一般情況下:
- 10 Mbps鏈路的默認(rèn)開銷值為 1
- 100 Mbps鏈路的默認(rèn)開銷值為 1
- 1 Gbps鏈路的默認(rèn)開銷值為 1
因此,根據(jù)鏈路的帶寬,可以計(jì)算出其對應(yīng)的成本值。在實(shí)際網(wǎng)絡(luò)部署中,也可以手動(dòng)配置鏈路的成本值,以便根據(jù)具體網(wǎng)絡(luò)情況進(jìn)行調(diào)整和優(yōu)化。
在路由器計(jì)算最短路徑時(shí),會(huì)考慮到各條路徑上的開銷值,選擇總成本最小的路徑作為最佳路徑進(jìn)行數(shù)據(jù)傳輸。因此,成本值在OSPF協(xié)議中扮演著重要的角色,影響著路由器的路由計(jì)算和數(shù)據(jù)傳輸路徑選擇。
二、配置需求及拓?fù)鋱D
配置需求
1、三層設(shè)備間配置ospf路由,進(jìn)程號為1;R1需要引入本地直連路由;R6、PC2間配置RIP路由;在R6上配置重分發(fā),將RIP發(fā)布到OSPF中;OSPF都需要宣告loopback地址。
2、在R1和R2上添加6個(gè)loopback地址,,模擬本地用戶網(wǎng)段,宣告匯總路由。
3、在R1、R2間配置接口認(rèn)證,明文密鑰為Test@123 ;在R2、R3、R4、R5、R6間配置區(qū)域認(rèn)證,使用md5加密,加密密鑰為Test@456。
3、修改相關(guān)屬性,PC1與PC2互通主鏈路為R1-R2-R4-R5;主鏈路故障時(shí)可以自動(dòng)切換到備用鏈路。
三、配置步驟
基礎(chǔ)配置不作描述
1、ospf的配置
R1
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
Change router-id and update OSPF process! [yes/no]:y
R1(config-router)#network 100.1.1.1 0.0.0.3 area 1
R1(config-router)#netw
R1(config-router)#network 1.1.1.1 0.0.0.0 area 1
R1(config-router)#exit
R2
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
Change router-id and update OSPF process! [yes/no]:y
R2(config-router)#netw
R2(config-router)#network 100.1.1.2 0.0.0.3 area 1
R2(config-router)#network 200.1.1.1 0.0.0.255 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#exit
R3
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
Change router-id and update OSPF process! [yes/no]:y
R3(config-router)#network 200.1.1.2 0.0.0.255 area 0
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
R3(config-router)#network 204.1.1.1 0.0.0.255 area 2
R3(config-router)#exit
R4
R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
Change router-id and update OSPF process! [yes/no]:y
R4(config-router)#network 4.4.4.4 0.0.0.0 area 0
R4(config-router)#network 100.1.1.3 0.0.0.255 area 0
R4(config-router)#network 204.1.1.2 0.0.0.255 area 2
R4(config-router)#exit
R5
R5(config)#router ospf 1
R5(config-router)#router-id 5.5.5.5
Change router-id and update OSPF process! [yes/no]:y
R5(config-router)#network 5.5.5.5 0.0.0.0 area 2
R5(config-router)#network 204.1.1.3 0.0.0.255 area 2
R5(config-router)#network 205.1.1.1 0.0.0.3 area 3
R5(config-router)#exit
R6
R6(config)#router ospf 1
R6(config-router)#router-id 6.6.6.6
Change router-id and update OSPF process! [yes/no]:y
R6(config-router)#network 6.6.6.6 0.0.0.0 area 3
R6(config-router)#network 205.1.1.2 0.0.0.3 area 3
R6(config-router)#exit
2、ospf虛鏈路
R3
R3(config)#router ospf 1
R3(config-router)#area 2 virtual-link 5.5.5.5 // 需要配置的為對端路由器ospf的Router-id,如果虛鏈路沒有配置成功,可以查看Router-id是否匹配
R3(config-router)#exit
R4
R4(config)#router ospf 1
R4(config-router)#area 2 virtual-link 5.5.5.5
R4(config-router)#exit
R5
R5(config)#router ospf 1
R5(config-router)#area 2 virtual-link 3.3.3.3
R5(config-router)#area 2 virtual-link 4.4.4.4
R5(config-router)#exit
查看虛鏈路狀態(tài)
3、RIP路由的配置及路由引入
重分發(fā)的路由必須是本地
show ip route
可以看到的路由
R6
R6(config)#router rip
R6(config-router)#version 2
R6(config-router)#no auto-summary
R6(config-router)#network 172.16.1.0
R6(config-router)#exit
R6(config)#router ospf 1
R6(config-router)#redistribute rip subnets // 重分發(fā)RIP路由
R6(config-router)#exit
R1
R1(config)#router ospf 1
R1(config-router)#redistribute connected subnets // 重分發(fā)直連路由
R1(config-router)#exit
4、宣告匯總路由
在宣告路由前,查看R2的路由表,可以發(fā)現(xiàn)學(xué)習(xí)了一大坨路由
R1
R1(config)#router ospf 1
R1(config-router)#summary-address 10.1.0.0 255.255.248.0 // 這里使用匯總的掩碼,不需要換算為反掩碼
R1(config-router)#exit
再次查看R2的路由表,此處替換為一條匯總路由
R2
R2(config)#router ospf 1
R2(config-router)#redistribute connected subnets // 需要先引入直連路由,否則宣告匯總路由無效
R2(config-router)#summary-address 10.1.0.0 255.255.224.0 // 宣告匯總路由
R2(config-router)#exit
查看R3的路由表,可以發(fā)現(xiàn)R1和R2的兩條匯總路由
5、區(qū)域認(rèn)證
5.1 明文接口認(rèn)證
R1
R1(config)#int g0/0
R1(config-if-GigabitEthernet 0/0)#ip ospf authentication
R1(config-if-GigabitEthernet 0/0)#ip ospf authentication-key Test@123
R1(config-if-GigabitEthernet 0/0)#exit
因?yàn)镽2還沒有配置認(rèn)證,所以會(huì)彈出錯(cuò)誤
R2
R2(config)#int g0/0
R2(config-if-GigabitEthernet 0/0)#ip ospf authentication
R2(config-if-GigabitEthernet 0/0)#ip ospf authentication-key Test@123
R2(config-if-GigabitEthernet 0/0)#exit
5.2 區(qū)域md5認(rèn)證
R2
R3(config)#router ospf 1
R3(config-router)#area 0 authentication message-digest // 開啟區(qū)域認(rèn)證
R3(config-router)#exit
R3(config)#int g0/1
R3(config-if-GigabitEthernet 0/1)#ip ospf message-digest-key 1 md5 5 Test@456 // 屬于該區(qū)域的接口上配置md5密鑰
R3(config-if-GigabitEthernet 0/1)#exit
R3
R3(config)#
R3(config)#router ospf 1
R3(config-router)#area 0 authentication message-digest
R3(config-router)#area 2 authentication message-digest
R3(config-router)#exit
R3(config)#int range g0/0-1
R3(config-if-range)#ip ospf message-digest-key 1 md5 Test@456
R3(config-if-range)#exit
R4
R4(config)#router ospf 1
R4(config-router)#area 0 authentication message-digest
R4(config-router)#area 2 authentication message-digest
R4(config-router)#exit
R4(config)#int range g0/0-1
R4(config-if-range)#ip ospf message-digest-key 1 md5 Test@456
R4(config-if-range)#exit
R5
R5(config)#router ospf 1
R5(config-router)#area 2 authentication message-digest
R5(config-router)#area 3 authentication message-digest
R5(config-router)#exit
R5(config)#int range g0/0-1
R5(config-if-range)#ip ospf message-digest-key 1 md5 Test@456
R5(config-if-range)#exit
R6
R6(config)#router ospf 1
R6(config-router)#area 3 authentication message-digest
R6(config-router)#exit
R6(config)#int g0/0
R6(config-if-GigabitEthernet 0/0)#ip ospf message-digest-key 1 md5 Test@456
R6(config-if-GigabitEthernet 0/0)#exit
5.3 虛鏈路認(rèn)證
R3
R3(config)#router ospf 1
R3(config-router)#area 2 virtual-link 5.5.5.5 message-digest-key 1 md5 Test@456
R3(config-router)#exit
R4
R4(config)#router ospf 1
R4(config-router)#area 2 virtual-link 5.5.5.5 message-digest-key 1 md5 Test@456
R4(config-router)#exit
R5
R5(config)#router ospf 1
R5(config-router)#area 2 virtual-link 3.3.3.3 authentication message-digest
R5(config-router)#area 2 virtual-link 4.4.4.4 authentication message-digest
R5(config-router)#area 2 virtual-link 3.3.3.3 message-digest-key 1 md5 Test@456
R5(config-router)#area 2 virtual-link 4.4.4.4 message-digest-key 1 md5 Test@456
R5(config-router)#exit
6、路由選路
查看PC1、PC2的默認(rèn)路徑,可以看到默認(rèn)走的R3
查看R4的g0/0接口的默認(rèn)開銷值
修改R3的開銷值
R3(config)#int range g0/0-1
R3(config-if-range)#ip ospf cost 10 // 同時(shí)修改開銷值為10
R3(config-if-range)#exit