◆passive-interface
- 可以用在rip eigrp ospf中。
其中在rip中是隻收不發報文
在eigrp不收不發報文
在ospf不收不發報文
路由協議進程中 network命令作用有兩個:
1,把network的地址網段的路由宣告進去,掩碼長度由接口配置決定,不是network決定
例如: network 10.0.0.1 0.0.0.255 就是把10.0.0.1-254的路由宣告,掩碼由接口配置決定
2,把network宣告的網段所在的接口宣告你路由協議
例如:network 10.0.0.1 0.0.0.254 把配置了10.0.0.1-254的接口通告出去
passive作用就是把第2作用取消了。就是會把10.0.0.1/24的路由通告出去,但是配置了10.0.0.1/24的接口不會再發送路由了
實驗:測試passive作用
1,配置IP,和loopback0
2,全網開啓eigrp
3, R1 :router ei 10
passive-interfa loopback 0
R3:仍然可以收到11.1.1.0的路由
R1 :debug eigrp packets 可看到不再從loopback0口發包。
passive-interface default 作用passive本地所有接口
##########################################################################################
################分發列表distribut-list控制路由更新流量
############################################################
- 使用access-list 或者 route-map 去允許或拒絕路由
- 應用與傳輸,接收,重分佈路由更新
- rip(in 。out方向) eigrp(in.out方向) ospf(in方向)
rip eigrp 在in方向,同時影響本地和下游
ospf在in方向,隻影響本地,不影響下游,因爲SPF算法
出方向更新
router(config-router)#
distribute-list {acce-list-number | name } out [interface-name| routing-process [routing-process parameter]]
入方向更新
router(config-router)#
distribut-list [access-list-number| name] | [route-map map-tag] in [interface-type interface-number]
實驗:測試不同路由協議 方向和影響範圍
一 距離矢量協議
1,啓用IP和eigrp或rip協議
2. R2再啓用loopback 1:11.1.2.1/24,但是不讓R3學習到
3,可以在R2 f1/0後R3 f0/0
R2: router ei 1
distribute-list 10 out fastethernet 1/0
access-list 10 deny 11.1.2.0
access-list 10 permit any
R3:sho ip ro 檢測
二 鏈路狀態協議
1,啓用ospf,都在區域 0
2,讓R2不能學到11.1.1.1
R2:
access-list 11 deny 11.1.1.1
access-list 11 permit any
router os 1
distribut-list 11 in
這樣就禁止了11.1.1.1寫入路由表,但是11.1.1.1的LSA不會受影響。
R2:sho ip os da 可看到11.1.1.1的lsa
############################################################################################################ OSPF 中過濾 3類LSA 前綴列表 ###################################
##################################################################
OSPF中是無法過濾LSA的 ,但是除了3類
控制3類LSA的數量兩種方法
1,彙總,ospf中有介紹
2,前綴列表
實驗:使用前綴列表,單獨控制一條3類lsa
1,R1 R2area0 R2 R3 area1
2,啓用IP和loopback
3,R1 lo0 11.1.0.1
lo1 11.1.1.1
lo2 11.1.2.1
控制R3不能學習到11.1.2.1
4, ABR路由器上:R2
ip prefix-list 名字 deny 11.1.2.1/32
ip prefis-list 名字 permit 0.0.0.0/0 le 32
router os 1
area 0 filter-list prefix 名字 out 或者
area 1 filter-list prefix 名字 in
sho ip os da 可看到11.1.2.1的age被置爲3600 LSA沒有 路由也肯定沒有
########################################################################################################################## 偏移列表 #############################
#########################################################################
RIP中 in out方向都可以,改變開銷跳數
eigrp 中 out方向修改了AD值
ospf中不存在offset-list命令
######################################################################################################################## 路由重分佈 ##############################################
- 一種臨時的協議轉換過程
- 不應該長期存在網絡中
重分佈進鏈路狀態路由協議中 使用subnet關鍵詞 防止只重分佈主類路由
重分佈ospf中,默認是OE1,默認cost=20
router ospf 1
redistribute eigrp 10 subnets
從分佈進距離矢量協議中,需要使用metric關鍵詞控制metric值。rip跳數 eigrp5個K值(帶寬,延時,可靠性,負載,MTU 。前兩個根據實際情況設置 1000 100 255 1 1500)。不控制metric默認是無窮大,將不生效
router eigrp 10
redistribute ospf 1 metric 1000 100 255 1 1500
或 種子度量值,針對所有重分佈
redistribute ospf 1
default-metric 1000 100 255 1 1500
將直連或靜態重分佈進距離矢量時不用加metric
直連的cost值就是接口的cost
靜態的cost值是靜態去往下一跳的cost
互相重分佈進的路由條目,就是R2本地中的 O 和 D 路由表條目
以及參與ospf和eigrp進程的接口的路由
重分佈前後,R2的路由條目不會變化
◆雙點雙向重分佈帶來的問題(eigrp不會有問題因爲eigrp內部90,外部170)
1:次優路徑----通過修改AD解決--distance
2:環路---通過過濾解決--distribute-list
R1: F0/0 1.1.12.1
F1/0 1.1.14.1
lo0 1.1.11.1
R2: F0/0 1.1.23.2
F1/0 1.1.12.2
lo0 1.1.22.1
R3: F0/0 1.1.23.3
F1/0 2.1.35.3
R4: F0/0 1.1.14.4
S1/0 2.1.45.4
R5: S1/0 2.1.45.5
F0/0 2.1.35.5
一 ,,次優路由
R3 :tracetoure 1.1.11.1 發現走的路徑是 R5->R4->R1->R2
因爲R3從RIP學到1.1.11.1 AD=120
從ospf學到1.1.11.1 AD=110
解決:減小RIP的AD,增加ospf的AD (distance 管理距離 鄰居的接口IP)
R3: router rip
distance 109 1.1.23.2 0.0.0.0 1 (1:acl匹配路由),如果直接默認全部會導致R1學R5的次優路由
access-list 1 per 1.1.0.0 0.0.255.255
sho ip ro
R4也要配置針對1.1.0.0 網段的distance
◆ospf進程中,修改distance 後面接鄰居的router-ID
R3: int lo0
ip add 33.1.1.1 255.255.255.0
router ospf 1
distance 100 55.1.1.1 0.0.0.0 2
access-list 2 permit 2.1.0.0 0.0.255.255
sho ip ro 從R5的學的路由AD就變了100,從R3學到的不變。
要修改R3的,需要增加 distance 100 33.1.1.1 0.0.0.0 2
總結:要修改從rip或eigrp學到路由的distance,要指向鄰居接口IP
要修改從ospf學到的路由的distance,要指向鄰居router-ID
LSA 和路由條目的區別
###############################################
############# distance:#############################################
● ospf可以修改默認AD(110)
router ospf 1
distance ospf external XXX inter-area XXX
sho ip ro 查看
● eigrp可以修改默認AD(90,170)
router eigrp 1
distance eigrp XX(內部) XX(外部)
sho ip protocal查看
● rip 不能修改
二,,雙點雙向從分佈 環路問題
R3 int l0
ip add 33.1.1.1 255.255.255.0
ip ospf 1 area 0
R4 traceroute R3 33.1.1.1看到環路現象
原因:R4從R5學到O的路由,當O的路由消失,還會從R1學到OE2的路由。然後R5 R1也學到OE2的,又重分佈給R2,這樣就環路了。。
通過distribute-list 過濾解決
R3:router ospf 1
distribute-list 10 out rip(所有重分佈進ospf的rip出方向路由都匹配ACL 10)
access-list 10 deny 33.1.1.0 0.0.0.255
access-list 10 deny 1.1.0.0 0.0.255.255
access-list 10 permit any
router rip
distribut-list 20 out ospf 1
access-list 20 deny 2.1.0.0 0.0.255.255
access-list 20 permit any
雙點在一個節點做就可以了。。
注意:使用distribute-list在協議之間做過濾時,只能是out方向
使用distribute-list方法解決環路的缺陷是:每增加一條路由就要寫一條ACL匹配!!
用route-map可以不因爲路由變更而更新配置。
R3:
rip 重分佈進ospf時,打tag 100
R4:deny tag=100
同理,把ospf 重分佈進 rip 的流量 打tag=200
步驟:
R3:
route-map rip2ospf deny 10
match tag 200
route-map ospf2rip permit 20
set tag 200
route-map rip2ospf permti 20
set tag 100
route-map ospf2rip deny 10
match tag 100
router ospf 1
redistribut rip subnets route-map rip2ospf
router rip
redistribute ospf 1 metric 5 route-map ospf2rip
R4:
route-map rip2ospf deny 10
match tag 200
route-map ospf2rip permit 20
set tag 200
route-map ospf2rip deny 10
match tag 100
route-map rip2ospf permit 20
set tag 100
router ospf 1
redis rip sub route-map rip2ospf
router rip
redis ospf 1 metric 5 route-map ospf2rip
#########################################################################################
################# route map ###########################################
#######################################################################
◆
- route map 類似於腳本語言
- 他們的工作就像一個更先進的訪問控制列表
自上而下的處理
一旦有一個匹配,立刻停止繼續匹配其他條件
- 有序號功能,方便編輯
插入操作
刪除操作
- route-map 使用命名的方式識別,而不是編號
- 匹配一個條件可以設置一個選項,類似於腳本語言中的 if then
◆路由圖的運行方式
- match語句可以匹配多個條件
- match語句匹配並排條件時 使用邏輯 或
- 至少要有一個被允許的路由進行重分佈
route-map my_bgp permit 10
match ip address X Y Z 邏輯或
route-map my_bgp deny 20
match aaa
match bbb
match ccc 邏輯與
- 定義多個match語句使用邏輯與
- 在重分佈裏所有匹配條件 必須要在路由表裏有一條實際的路由
- 使用路由圖進行重分佈過濾時,允許或者拒絕的只是是否要被重分佈。
◆route-map 的應用
route-map的主要功能
- 重分佈時的過濾:使用更先進的方式來確定重分佈的內容
- 基於策略的路由(PBR):依據需求使用其他的標準來確定去往目的路由的轉發方式
- BGP 策略執行:是BGP 路由策略的主要界定工具
PBR:首先理解路由表的作用(3個)
路由轉發基於路由表,有則轉發,無則丟棄
直連自動生成路由
路由匹配遵循最長匹配
PBR就是可以根據策略路由數據表,不用看路由表內容。
◆route-map 命令
- 定義route-map名字和類型
router(config)#
route-map map-tag [permit | deny] [sequence-number]
- 定義匹配條件
router(config-route-map)#
match {conditions}-----ACL或前綴列表或接口or tag
- 定義匹配了條件而執行的動作
router(config-route-map#
set {actions}
- 可以詳細控制路由被重分佈到路由協議
router(config-router)#
redistribute protocol [process id] route-map-tag
match 命令
router(config-route-map)#
match定義匹配的條件
這裏的是否匹配直接影響了重分佈的操作
match {options}:
ip address ACL
ip route-source ACL
ip next-hop ACL
interface type number
metric metric-value
route-type [external | internal | level-1 | level-2 | local]
route-map 重分佈
router(config)#router ospf 10
router(config-router)# redistribute rip router-map-redis-rip subnets
- 匹配ACL 23 或29 的路由條目被重分佈到ospf中的 度量爲500 外部類型爲1
- 匹配ACL 37的路由條目不能被重分佈
- 所有其他的路由被重分佈到ospf的度量值我5000外部類型
router(config)#
route-map redis-rip permit 10
match ip address 23 29
set metric 500
set metric-type type-1
route-map redis-rip deny 20
match ip address 37
route-map redis-rip permit 30
set metric 5000
set metric-type type-2
沒有match語句,就是match所有的意思
router(config)#
access-list 23 permit 10.1.0.0 0.0.255.255
access-list 29 permit 172.16.1.0 0.0.0.255
access-list 37 permit 10.0.0.0 0.0.0.255
實驗部分:
步驟:
1,簡化拓撲,down掉R4 R5
2,配置匹配數據流
access-list 11 permit 1.1.11.0
access-list 12 permit 1.1.12.0
access-list 14 permit 1.1.14.0
access-list 22 permit 1.1.22.0
access-list 23 permit 1.1.23.0
2, R2:
route-map test per 10
match ip address 11
set metric-type type-2
route-map test permit 20
match ip add 12
set metric 70
route-map test permit 30
match ip add 14
set metric 80
route-map test permit 40
match ip add 22
set metric-type type-1
route-map test deny 50
match ip add 23
route-map test permit 9999-->設置較大數值,以便日後插入新的route-map語句
router ospf 1
redistribute rip subnets route-map test
3, R5:
sho ip ro 查看
總結
- passive-interface命令用來控制路由更新
- 分佈列表使用ACL 去控制路由更新
- 分佈列表可以用於接口中 也可以用於路由重分佈
- route-map是一個比較複雜的工具,用於各種操縱和過濾,如果符合條件,則使用動作
- 使用route-map可以簡化在重分佈張總控制路由條目的難度
- 管理距離是一種在一個路由器上運行多個路由協議,從而評估該路由協議選擇的路徑的可信度
- COSCO iOS 爲每個路由協議都分配一個值,這個值可以修改
- 在重分佈中,管理距離的修改可以使路由的操作更準確
##################################################################################################################### PBR #################################
#################################################################
- 通過route-map 實現
- 在路由表之上
步驟:
1,啓用IP
2,R3啓用loopback
3,全網ospf
正常R1-->R3 路徑是 R1 R2 R3
實驗需求:
R1-->R3 路徑是 R1 R2 R4 R3
步驟:
1,R2 使用ACL抓流量
access-list 10 permint 12.1.1.0 0.0.0.255
2, 設置路徑
route-map PBR permit 10
match ip add 10
set ip next-hop 24.1.1.4
3, 接口調用
int f0/0
ip policy route-map PBR
4,驗證
R1 traceroute 33.1.1.1
注意:PBR有自動檢測下一跳出接口是否連通功能,當下一跳不可達時,PBR自動失效,數據重 新根據路由表查詢路徑
###### PBR track 功能 #############
####################################
當R4 出問題時,PBR就不能檢測到了。(R4 shut f0/0)
利用tack驗證 下一跳的可達性
1,啓用track
route-map PBR permit 10
set ip next-hop verify-availability 24.1.1.4 1(1表示定義首選下一跳) track 1
2,定義track
track 1 rtr 1 reachability
3,使用SLA 驗證可達性
ip sla monitor 1(1 與rtr的1對應)
type echo protocol ipicmpecho 24.1.1.4
frequency 5 (定義刷新頻率,默認60秒)
4,SLA 開始時間 存活時間
ip sla monitor schedule 1 life forever start-time now
5,查看
show ip sla monitor statistics
show track
show route-map
6, 驗證
R4 :int f0/0
shut
R1 ping 33.1.1.1
###########################################################################################
理解 forward-address
1,R1 F0/0 123.1.1.1
F1/0 12.1.1.1
R2 f0/0 123.1.1.2
f1/0 12.1.1.2
R3 f0/0 123.1.1.3
2, 起ospf eigrp
3,R2 eigrp重分佈進ospf
當存在forward-address時,必須是ospf路由表中可達的地址,才能通信
4,R3 ip route 0.0.0.0 0.0.0.0 123.1.1.1
5, R1 trace R3 要繞路到R2
6,sho ip os da ex 33.1.1.0
沒有forward-add
6, R1:
router os 1
net 123.1.1.0 0.0.0.255 a 0
7, R2:
sho ip os ex 33.1.1.0 出現了forward-add 123.1.1.3
但是R2 不能通過ospf可達123.1.1.3(雖然可以通過直連可達),所以 33.1.1.0網段也就消失了
8,R2:把與R3的直連口也宣告進ospf,讓33.1.1.0的forward-add通過ospf學到,
router ospf 1
net 123.1.1.0 0.0.0.255 a 0
此時再trace 33.1.1.1 路徑就是R2---R3
###################################################################################