重分佈及路由匹配控制
重分佈
重分佈可以連接運行不同路由協議的接口,使其單向傳遞路由表,及重分佈只能單向傳遞,如果雙向傳遞,需要配置兩條重分佈
- 重分佈進入RIP協議的區域(默認metric值爲無窮大,所以需要手動指定metric值)
router rip
redistribute {eigrp 1 | ospf 1} metric 3
- 重分佈進入EIGRP協議的區域(默認metric值爲無窮大,所以需要手動指定metric值)
router eigrp 1
redistribute {rip | ospf 1} metric _ _ _ _ _
- 重分佈進入OSPF協議的區域
router ospf 1
redistribute {rip | eigrp 1} subnets
路由匹配及控制
1.ACL
- 控制流量
- 匹配主機
用法:
access-list 1 permit 192.168.1.0 (抓取路由,單個IP)
access-list 1 permit 192.168.1.0 0.0.0.255 (抓取流量)
ip access-list {standard | extend} 編號
標準,只匹配源
拓展,匹配源目的,以及網絡協議,端口
最後在接口處配置ip access-group 1 in
2.prefix-list(前置列表)
只抓取路由,不進行流控,精確抓取路由
用法:
ip prefix-list a permit 網段 [ge,le] 數字 [ge,le] 數字
注意: le後的數字> ge後的數字>網絡掩碼
router eigrp 1
distribute-list prefix-list a {in | out} e0/0
事例:
ip prefix-list a permit 0.0.0.0/0 只允許默認路由通過網關
ip prefix-list a permit 0.0.0.0/0 le 32 所有路由
ip prefix-list a permit 0.0.0.0/0 ge 32 主機
ip prefix-list a permit 10.0.0.0/8 ge 24 le 24 匹配第一個8位爲10且掩碼爲24位的ip(包含10.0.1.0/24)
offset-list(偏移列表)
在距離矢量路由協議(RIP,EIGRP)的網絡中,對路由的metric進行增大
access-list 1 permit 1.1.1.0 0.0.0.255 (這裏需要注意如果不加反掩碼則只匹配單個ip)
router rip
offset-list 1(ACL編號) {in|out} 2(偏移量) e0/0
分發列表
控制傳入或傳出的路由,當傳出時{發|不發}某些路由,當接收時{接收|不接收}某些路由
ip prefix-list a deny 1.1.1.1/24
ip prefix-list a permit 0.0.0.0/0 le 32
router rip
distribute-list prefix a {in|out} e0/0
- 在距離矢量協議的網絡中配置in和out均有效,影響下游路由器
- 在鏈路狀態協議的網絡中只有in有效,不會影響下游路由(除非是本地始發的外部路由,ASBR)
補充:
fiilter-list在ospf的ABR上過濾LSA
area 1 filter-list prefix a {in|out}
Route-map(路由策略)
- match 匹配需要操作的路由
1.match ip address x,y,z(匹配x或y或z)
2.match ip address x
match ip address y
(匹配x且y)
不寫match匹配所有路由
不寫set不做操作
需要在路由源設置
- set設置路由的參數
router-map name permit 編號
match ip addres net wild-card
set {meric|metric_type}
PBR(策略路由)
優先於路由表指定數據包的走向
int e0/0
ip policy route-map name
以上配置只適用於穿越該路由器的流量,如需對本地流量生效,則需配置ip local policy router-map a
Passive-interface
屏蔽指定接口的路由協議報文
在RIP中只收不發(不需要建立鄰居關係)
在OSPF和EIGRP中不收不發(需要建立鄰居關係)
(應用實例:在接入層連接的路由器端口配置passive-interface可避免路由協議泄露)
router rip
passive-interface inte0/0
passive-interface default
no passive-interface e0/0
AD(administrative distance)
管理距離
Router source | Default distance |
---|---|
connect | 0 |
static | 1 |
EIGRP | 5 |
External BGP | 20 |
Internal BGP | 90 |
IGRP | 100 |
OSPF | 110 |
ISIS | 115 |
RIP | 120 |
External EIGRP | 170 |
Internal EIGRP | 200 |
unknown | 255 |