match regex
要标识正则表达式类映射中的正则表达式,请在 class-map type regex 配置模式下使用 matchregex 命令。要从类映射中删除正则表达式,请使用此命令的 no 形式。
matchregex名称
nomatchregexname
Syntax Description
name |
通过 regex 命令添加的正则表达式的名称。 |
Command Default
无默认行为或值。
Command Modes
下表展示可输入命令的模式:
命令模式 |
防火墙模式 |
安全情景 |
|||
---|---|---|---|---|---|
路由 |
透明 |
一个 |
多个 |
||
情景 |
系统 |
||||
类映射类型正则表达式配置 |
|
|
|
— |
|
Command History
版本 |
修改 |
---|---|
7.0(2) |
添加了此命令。 |
Usage Guidelines
regex 命令可用于需要文本匹配的各种功能。您可以使用 class-maptyperegex 命令,然后使用多个 matchregex 命令,对正则表达式类映射中的正则表达式进行分组。
例如,您可以使用检查策略图配置应用程序检查的特殊操作(参见 policymaptypeinspect 命令)。在检测策略映射中,您可以创建包含一个或多个 match 命令的检测类映射,标识要对其执行操作的流量,也可以直接在检测策略映射中使用 match 命令。某些 match 命令可使用正则表达式标识数据包中的文本,请参阅;例如,可以匹配 HTTP 数据包内的 URL 字符串。
Examples
以下是 HTTP 检测策略映射和相关类映射的示例。此策略映射由第 3/4 层策略映射激活,而第 3/4 层策略映射由服务策略启用。
ciscoasa(config)# regex url_example example\.com
ciscoasa(config)# regex url_example2 example2\.com
ciscoasa(config)# class-map type regex match-any URLs
ciscoasa(config-cmap)# match regex url_example
ciscoasa(config-cmap)# match regex url_example2
ciscoasa(config-cmap)# class-map type inspect http match-all http-traffic
ciscoasa(config-cmap)# match req-resp content-type mismatch
ciscoasa(config-cmap)# match request body length gt 1000
ciscoasa(config-cmap)# match not request uri regex class URLs
ciscoasa(config-cmap)# policy-map type inspect http http-map1
ciscoasa(config-pmap)# class http-traffic
ciscoasa(config-pmap-c)# drop-connection log
ciscoasa(config-pmap-c)# match req-resp content-type mismatch
ciscoasa(config-pmap-c)# reset log
ciscoasa(config-pmap-c)# parameters
ciscoasa(config-pmap-p)# protocol-violation action log
ciscoasa(config-pmap-p)# policy-map test
ciscoasa(config-pmap)# class test
[a Layer 3/4 class map not shown]
ciscoasa(config-pmap-c)# inspect http http-map1
ciscoasa(config-pmap-c)# service-policy test interface outside