Route-Map:功能性很是強的策略列表,能夠用來過濾路由也能夠調整路由的屬性,自身具有過濾功能。
Route-Map的做用:
1.在重發布的過程當中作route-map,重發布過程當中能夠改變路由的屬性;(次要做用)
例如但願在路由被注入RIP後,192.168.1.0路由的metric爲1,2.0的metric爲2如此這般呢?傳統的重發布是沒辦法作到的。 那麼就可使用route-map這個工具,也就是說,咱們能夠在執行重發布的時候,關聯一個route-map,來實現剛纔的這個功能。
2.NAT(網絡地址轉換); (次要做用)
3.PBR 策略路由;(次要做用)
4.BGP(基於屬性的路由選路) ;(主要做用)redis
應用在重分佈,接口( PBR), BGP。
Route-map用在重分佈中,
Route-Map的邏輯語句:
利用 ACL 抓取路由條目,
Access-list 1 permit 12.1.1.1 0.0.0.0(路由條目)
配置 route-map
route-map test permit/deny 10 ( 建立route-map 名字爲test 容許或拒絕序號爲10
match x1(ip address access-list 1)
match x2,x3
set Y
route-map test permit/deny 20
match x4
set Y
應用 route-map,
Router ospf 100
Redistribute rip subnets route-map test網絡
注意:
1.Route-Map末尾隱含拒絕全部,因此最後要寫容許全部的語句;
Route-map test permit 20
表明容許全部。
2.若是沒有set語句的話,set nothing(什麼都不作);
3.若是沒有match語句的話,match all(匹配全部);
4.在重發布過程當中使用Route-Map,切記在使用ACL或Prefix-List抓取路由的時候只能使用permit,策略的制定執行由Route-Map完成。ide
1.Match語句,匹配的做用,自上而下的匹配順序;
匹配動做將會從最小的序列號開始執行,若是該序列號中的條件都被匹配了則執行set命令,若是條件不匹配,則切換到下一個序列號繼續進行匹配動做。
2.Set語句,執行的做用;
set tag 99 打標99
set type 1
Set metric1 度量值1
set metric-type type-1 (設置OSPF 的開銷類型、分爲類型1(type-1和類型2(type-2。類型1的計算方法是外部開銷(即重發布路由時開銷)再加上路由器到ASBR的開銷,類型2的計算方法是開銷=外部開銷。
v以下:
A---B----C
好比C引入一個外部路由到ospf,設定metric爲100
默認引入的時候是type2的,這樣B計算出的花費就是100,A也是100
若是設置成type1的,B計算的是100+1=101,A計算的是100+2=102。工具
定義匹配條件
match ip address access-list 1 (prefix-list 1) 匹配訪問列表或前綴列表
match length 根據分組的第三層長度進行匹配
match interface 匹配下一跳出接口爲指定接口之一的路由
match ip next-hop 匹配下一跳地址爲特定訪問列表中被容許的那些路由
match metric 匹配具備指定度量值的路由
match route-type 匹配指定類型的路由
match community 匹配BGP共同體
match tag 根據路由的標記進行匹配3d
定義set動做
set metric 設置路由協議的度量值
set metric-type 設置目標路由協議的度量值類型
set default interface 指定如何發送這樣的分組
set interface 指定如何發送這樣的分組
set ip default next-hop指定轉發的下一跳
set ip next-hop 指定轉發的下一跳
set next-hop 指定下一跳的地址,指定BGP的下一跳
set as-path
set community
set local-preference
set weight
set origin
set tag
default 關鍵字優先級低於明細路由code
1.Access-list
Access-lsit 1 permit/deny 12.1.1.0
Router ospf 1
Distribute-list 1router
2.Prefix-list
ip prefix-list test permit/deny 12.1.1.0 255.255.255.0
Route-map test permit 10
Match ip address prefix-list testblog
3.Metric(RIP和OSPF間路由重發布)
Route-map rip2ospf permit 10
Match metric 6
Router ospf 1
Redistribute rip subnets route-map rip2ospf接口
4.metric(rip和ospf間路由重發布)
Route-map ospf2rip permit 10
Match metric 101
Router rip
redistribute ospf route-map ospf2rip metric 1ip
5.metric(bgp和ospf間路由重發布)
Route-map bgp2ospf1 permit 10
Match metric 200
Router-map bgp2ospf2 permit 10
Match metric 100
Router ospf 1
Redistribute bgp 1 subnets route-map bgp2ospf1
Router ospf 2
Redistribute bgp 1 subnets route-map bgp2ospf2
6.tag
就是在重發布時給路由打標籤
redistribute rip subnet tag 1
意味着把rip重發布進入ospf,而後給全部重發布的rip路由打上tag 爲 1 ,作個標記,方便在作策略時整個調用(在抓路由時能夠規定抓取全部tag=1 的路由)
Redistribute bgp 1 subnets tag 10
route-map實例:
R1(config)#
interface e 0/1
ip address 12.1.1.1 255.255.255.0
no shutdown
interface lo 0
ip address 1.1.0.1 255.255.255.0
interface lo 1
ip address 1.1.1.1 255.255.255.0
interface lo 2
ip address 1.1.2.1 255.255.255.0
interface lo 3
ip address 1.1.3.1 255.255.255.0
router rip
version 2
network 12.1.1.0
network 1.1.0.0
network 1.1.1.0
network 1.1.2.0
network 1.1.3.0
no auto-summary
R2(config)#
interface e 0/1
ip address 12.1.1.2 255.255.255.0
no shutdown
interface e 0/3
ip address 23.1.1.2 255.255.255.0
no shutdown
router rip
version 2
network 12.1.1.0
no auto-summary
interface e 0/3
router ospf 100
router-id 2.2.2.2
network 23.1.1.0 0.0.0.255 area 1
R3(config)#
interface e 0/3
ip address 23.1.1.3 255.255.255.0
no shutdown
router ospf 100
router-id 3.3.3.3
network 23.1.1.0 0.0.0.255 area 1
查看R二、R3 路由圖
show ip route
發現R3 並無R1 的路由信息
如今經過在R2 重發布把RIP 信息發佈到OSPF 裏面、而且調用 route-map定製的好的控制列表、使得R3 有規則的仿問R1 。
R2(config)#
1.抓取路由條目:
ip prefix-list permit0 permit 1.1.0.0/24
命名爲permit0前綴列表容許1.1.0.0/24網段經過
ip prefix-list permit1 permit 1.1.1.0/24
ip prefix-list permit2 permit 1.1.2.0/24
ip prefix-list permit3 permit 1.1.3.0/24
access-list 1 permit 12.1.1.0 0.0.0.255
訪問控制列表1 容許12.1.1.0網段經過
2.制定Route-Map:
route-map rip2ospf deny 10
( 建立route-map 名字爲rip2ospf 拒絕 序號爲10
match ip address prefix-list permit0
(匹配 permit0名的前綴列表
route-map rip2ospf permit 20
match ip address prefix-list permit1
set metric-type type-1
(設置OSPF 的開銷類型爲類型1
route-map rip2ospf permit 30
match ip address prefix-list permit2
set metric 200
(設置度量值200
route-map rip2ospf permit 40
match ip address prefix-list permit3
set tag 333
(打標333
route-map rip2ospf permit 50
match ip address 1
set tag 111
3.重發布過程當中調用Route-Map:
exit
router ospf 100
redistribute rip subnets route-map rip2ospf
(把rip重發布到ospf中、發佈過程當中調用<rip2ospf名的>Route-Map
查看R3 路由表。 show ip route show ip route ospf show ip ospf database