天天看点

ASA防火墙上做基于域名的URL过滤

实验

实验拓扑图:

ASA防火墙上做基于域名的URL过滤

实验环境:

在server2008服务器上搭建WEB网站和DNS服务,分别创建域名为benet.com和accp.com两个网站。

实验要求:

首先客户端可以访问服务器上的两个网站,成功后在防火墙上做URL过滤使客户端无法访问accp.com网站。

实验步骤:

首先在ASA防火墙上配置各区域名称和IP地址:

ciscoasa(config)# int e0/0

ciscoasa(config-if)# nameif inside

ciscoasa(config-if)# ip add 192.168.10.1 255.255.255.0

ciscoasa(config-if)# no shut

ciscoasa(config-if)# int e0/1

ciscoasa(config-if)# nameif outside

ciscoasa(config-if)# ip add 13.0.0.1 255.255.255.0

在服务器上创建两个网站,指定网站存放位置和域名:

创建accp.com网站:

ASA防火墙上做基于域名的URL过滤

创建benet.com网站:

ASA防火墙上做基于域名的URL过滤

指定DNS主机A记录:

ASA防火墙上做基于域名的URL过滤
ASA防火墙上做基于域名的URL过滤

测试用客户端访问者两个网站:

ASA防火墙上做基于域名的URL过滤
ASA防火墙上做基于域名的URL过滤

测试访问成功:

接下来在防火墙上做URL过滤使客户端无法访问accp.com网站。

ASA上的配置:

做URL过滤需要下面三个步骤;

url过滤

一, 创建class-map (类映射),识别传输流量。

ciscoasa(config)# access-list aclfile permit tcp 192.168.10.0 255.255.255.0 an$   //定义ACL访问控制列表aclfile。

ciscoasa(config)# class-map aclclass   //建立类映射aclclass。

ciscoasa(config-cmap)# match access-list aclfile  //匹配访问控制列表。

ciscoasa(config-cmap)# regex url "\.accp\.com"  //定义正则表达式,过滤不允许访问的网站。

ciscoasa(config)# class-map type regex match-any urlclass  //建立类映射urlclass,关键字match-any表示匹配任何一个。

ciscoasa(config-cmap)# match regex url  //调用匹配正则表达式。

ciscoasa(config-cmap)# ex

ciscoasa(config)# class-map type inspect http httpclass  //建立检查流量的类映射

ciscoasa(config-cmap)# match request header host regex class urlclass  //调用之前已配置好的urlclass。

二, 创建policy-map (策略映射),关联class-map

ciscoasa(config)# policy-map type inspect http httppolicy  //建立策略映射。

ciscoasa(config-pmap)# class httpclass  //调用已经做好的检查http头部的类映射。

ciscoasa(config-pmap-c)# drop-connection log   //丢弃并记录日志。

ciscoasa(config-pmap-c)# policy-map insidepolicy  //对访问控制列表进行操作,定义相应策略。

ciscoasa(config-pmap)# class aclclass  //调用访问控制列表的类映射。

ciscoasa(config-pmap-c)# inspect http httppolicy  //检查定义好的策略映射。

三, 应用class-map到接口上。

ciscoasa(config)# service-policy insidepolicy interface inside //应用在端口。

测试使用客户端访问accp.com网站:

ASA防火墙上做基于域名的URL过滤

结果显示为无法访问: