路由控制:

访问控制列表,前缀列表,route-map


访问控制列表:

ACL

分类:标识流量进行特殊处理

过滤:通过过滤流经路由器的流量对网络进行管理

ACL编号:

标准ACL编号:1-99,1300-1999

拓展ACL编号:100-199,2000-2699

ACL写完之后,系统默认加deny any,无法用sh命令查看,所以如果有必要需要加上acce 1 per any

sh ip acce 查看所有的acl信息

标准acl

抓流量!

acce [编号] per/deny [源地址] [反掩码]

如果需要acce [编号] per any 放行其他的

抓路由!

acce 10 per host 1.1.1.0 = acce 10 per 1.1.1.0 0.0.0.0 = acce 10 per 1.1.1.0

一般在某些分发列表,偏移列表等地方调用

在接口调用的都是抓流量用

(config-if)

ip acce [编号] in/out

-——————–

1.1.1.0

1.1.2.0

1.1.3.0

1.1.0.0 0.0.3.0(后面其实是叫通配符)

-——————–

拓展acl:

检查源地址和目的地址

还可以搞特定的端口和程序

精确和不精确匹配掩码

抓源目流量

acce [编号] deny/per [协议] [源地址] [反掩码] [目的地址] [反掩码]

acce [编号] per ip any any 如果有必要的话!

抓端口流量

acce 100 per tcp/udp [源地址] [反掩码] eq/gt/lt/neq [协议/端口]

access-list 100 per tcp 1.1.1.0 0.0.0.255 4.4.4.0 0.0.0.255 eq 80 只允许1去访问4的80


其他配置方法:

(config)

ip acce st/ext [编号]

10 per xxxxx

20 per xxxxx

如果要删,no 10

创建自命名的acl

ip acce st/ext [名字]


前缀列表

只能抓路由,不能抓数据包

(config)

ip pre [列表名] per/deny [网段/通配符] le/ge [多少位]

le代表定义最大掩码长度

ge代表定义最小掩码长度

sh ip pre 查看前缀列表

ip pre test per 3.3.3.0/24 代表前24位必须匹配

ip pre test per 3.3.3.0/24 le 30 前24位必须匹配,掩码必须小于等于30,同时大于等于24位

ip pre test pre 3.3.3.0/24 ge 26 前24位必须匹配,掩码必须大于等于26位

ip pre test per 3.3.3.0/24 ge 26 le 28 掩码必须大于等于26位小于等于28位

ip pre test per 0.0.0.0/0 le 32相当于permit any

ip pre test per 0.0.0.0/1 le 32 抓A类路由

ip pre test per 128.0.0.0/2 le 32 抓B类路由

ip pre test per 192.0.0.0/3 le 32 抓C类路由


eigpr重发布ospf

redis os 1 me 1000 100 255 1 1500

在ospf重发布eigrp

redis ei 1 sub

R2

ip prefix-list test: 2 entries

  seq 5 deny 11.1.1.1/32

  seq 10 permit 0.0.0.0/0 le 32

router ei 1

distr pre test out os 1在eigrp的进程里告诉其他eigrp1的同伴我分发的路由按照prefix-list抓到的为标准,这路由来自ospf 1里


route-map

可以做到过滤和修改路由属性

应用:

1.重发布的时候做路由控制

2.PBR(基于策略的路由)policy-based routing

3.BGP选路

acce 1 per 3.3.3.0 用acl抓取3.3.3.0的路由

ip pre test per 4.4.4.0/24 用前缀列表抓4.4.4.0的路由

route-map E2O per 10 第一条route-map

mat ip add 1 匹配acl1的内容

set metric 99 为这个内容抓取的路由设置metric为99

route-map E2O per 20

mat ip add pre test

set metric 98

route-map E2O per 30 加上空语句,意思per anying,set nothing

(config-router)

比如在ospf里重发布eigrp

redis ei 1 sub route-map E2O


PBR权限优于路由表

调用的时候必须在数据包的in方向调用!!!!

在分界的地方

acce 1 per 1.1.1.1 0.0.0.0

route-map PBR per 10

mat ip add 1

set ip next-hop 192.168.34.4

【set int [出接口]】

int [入接口]

ip policy route-map PBR


注意

route-map匹配路由,不匹配的路由会被drop(需要写空语句)

route-map匹配数据,不匹配的数据会按照原来的方式进行转发(不需要写空语句)


综合

1.在路由器上,允许来自1.1.1.0网段的流量通过

acce 1 per 1.1.1.0 0.0.0.255

2.允许来自1.1.1.0网段的流量去访问4.4.4.0网段

acce 100 per ip 1.1.1.0 0.0.0.255 4.4.4.0 0.0.0.255

3.拒绝来自1.1.1.0网段的流量,但是允许其他的

acce 1 deny 1.1.1.0 0.0.0.255

acce 1 per any

4.允许1.1.1.1 telnet 4.4.4.4 的流量通过,其他拒绝

acce 100 per tcp host ()1.1.1.1 host 4.4.4.4 eq telnet

5.抓出1.1.1.0的路由

acce 1 per 1.1.1.0 0.0.0.0

6.用一条acl抓出1.1.0.0 1.1.1.0 1.1.2.0 1.1.3.0四个子网

acce 1 per 1.1.0.0 0.0.3.0

7.用一条语句抓出1.1.0.0-1.1.255.0/24之间所有子网号为奇数的路由

acce 1 per 1.1.1.0 0.0.254.0