一.概述:
QQ群里面有网友讨论ASA防火墙的policy-map的global和interface的执行顺序,从字面意思可以看出这两种的应用范围是不一样的,一个是全局调用,一个只在接口下调用,因此觉得是详细的interface被优先调用,为了确认自己的想法,决定搭建环境验证一下。
二.基本思路:
A.不相冲突的policy-map估计会被全局和接口的service-policy先后调用执行,看不出效果
B.只能用相冲突的policy-map,在全局和接口的service-policy中同时调用,看最终哪个生效
C.全局和接口的policy-map执行范围是不一样的,估计接口的policy-map会被优先调用执行,顺序可能为:
①.先执行接口的service-policy,并调用对应的policy-map,如果被匹配,则不执行全局的service-policy
②.如果不被接口的policy-map所匹配,则会接着执行全局的service-policy,并调用对应的policy-map
----经过测试,发现跟想象的有点区别:如果被接口policy-map审查通过,是会送到全局policy-map的;除非被接口的class-map的ACL丢弃,或者被审查后丢弃。
三.测试拓扑:
10.1.1.0/24(Inside) 200.100.1.0/24(Outside)
PC1(.8)----------------------(.1)ASA842(.1)----------------------------(.8)PC2
web服务器端口为:2000
四.基本配置:
A.PC1:
IP:10.1.1.8/24 ,GW:10.1.1.1
B.ASA842防火墙:
①接口配置:
interface GigabitEthernet0
nameif Inside
security-level 100
ip address 10.1.1.1 255.255.255.0
no shut
interface GigabitEthernet1
nameif Outside
security-level 0
ip address 202.100.1.1 255.255.255.0
no shut
②动态PAT配置:
object network Inside.net
subnet 10.1.1.0 255.255.255.0
object network Inside.net
nat (Inside,Outside) dynamic interface
③静态PAT配置:
object network Inside.pc1
host 10.1.1.8
object network Inside.pc1
nat (Inside,Outside) static interface service tcp 2000 2000
④策略设置:
access-list outside extended permit tcp any object Inside.pc1 eq 2000
access-group outside in interface Outside
五.测试步骤:
A.验证此时外网是否能正常访问内部web服务器:
----无法访问,因为默认全局策略开启了skinny审查
B.配置outside接口的policy-map并调用:
access-list web2000 extended permit tcp any object Inside_pc1 eq 2000
class-map web2000
match access-list web2000
policy-map web2000
class web2000
inspect http
service-policy web2000 interface Outside
C.验证此时外网是否能正常访问内部web服务器:
---仍然无法访问
ciscoasa# show service-policy
Global policy:
Service-policy: global_policy
Class-map: inspection_default
.....省略部分..................
Inspect: ip-options _default_ip_options_map, packet 0, drop 0, reset-drop 0
Inspect: skinny , packet 4, drop 1, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
Interface Outside:
Service-policy: web2000
Class-map: web2000
Inspect: http, packet 4, drop 0, reset-drop 0
---可以看到,数据包虽然被接口下class-map审查合格后放行,但是却被全局下的class-map丢弃。
D.调整outside接口的policy-map并调用:
access-list outside_skinny extended deny tcp any object Inside_pc1 eq 2000
access-list outside_skinny extended permit tcp any any eq 2000
class-map outside_skinny
match access-list outside_skinny
policy-map outside_skinny
class outside_skinny
inspect skinny
no service-policy web2000 interface outside
service-policy outside_skinny interface Outside
E.验证此时外网是否能正常访问内部web服务器:
---可以正常访问
访问之前,clear service-policy,访问完成之后再查看:
ciscoasa# show service-policy
Global policy:
Service-policy: global_policy
Class-map: inspection_default
.....省略部分..................
Inspect: ip-options _default_ip_options_map, packet 0, drop 0, reset-drop 0
Inspect: skinny , packet 0, drop 0, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
Interface Outside:
Service-policy: outside_skinny
Class-map: outside_skinny
Inspect: skinny , packet 0, drop 0, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
----可以发现访问前后全局和接口的class-map都没有被匹配
F.调整全局和接口policy-map:
①接口:
access-list outside_skinny extended permit tcp any any eq 2000
class-map outside_skinny
match access-list outside_skinny
policy-map outside_skinny
class outside_skinny
inspect skinny
service-policy outside_skinny interface Outside
②全局:
access-list global_skinny extended deny tcp any object Inside_pc1 eq 2000
access-list global_skinny extended permit tcp any any eq 2000
class-map global_skinny
match access-list global_skinny
policy-map global_policy
class inspection_default
no inspect skinny
class global_skinny
service-policy global_policy global
③测试:
----无法访问,被outside接口的policy-map拒绝
ciscoasa# show service-policy
Global policy:
Service-policy: global_policy
Class-map: inspection_default
........省略部分..............
Inspect: ip-options _default_ip_options_map, packet 0, drop 0, reset-drop 0
Class-map: global_skinny
Inspect: skinny , packet 0, drop 0, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
Interface Outside:
Service-policy: outside_skinny
Class-map: outside_skinny
Inspect: skinny , packet 4, drop 1, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
----可以看到,因为outside的ACL没有明确拒绝流量,所以被匹配,并检测到不是skinny流量而被丢弃
G.再次调整全局和接口的policy-map:
①接口:
access-list outside_skinny extended deny tcp any object Inside_pc1 eq 2000
access-list outside_skinny extended permit tcp any any eq 2000
class-map outside_skinny
match access-list outside_skinny
policy-map outside_skinny
class outside_skinny
inspect skinny
service-policy outside_skinny interface Outside
②全局:
access-list global_skinny extended permit tcp any any eq 2000
class-map global_skinny
match access-list global_skinny
policy-map global_policy
class global_skinny
inspect skinny
service-policy global_policy global
③测试:
----可以正常访问
ciscoasa# show service-policy
Global policy:
Service-policy: global_policy
Class-map: inspection_default
.......省略部分....................
Inspect: ip-options _default_ip_options_map, packet 0, drop 0, reset-drop 0
Class-map: global_skinny
Inspect: skinny , packet 0, drop 0, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
Interface Outside:
Service-policy: outside_skinny
Class-map: outside_skinny
Inspect: skinny , packet 0, drop 0, reset-drop 0
tcp-proxy: bytes in buffer 0, bytes dropped 0
----可以发现outside接口的ACL配置了拒绝后,不会去匹配全局的policy-map。
六.总结:
A.处理顺序:先接口再全局
B.是否会送到全局:如果没有被接口policy-map匹配,或被接口policy-map审查通过,会被送到全局
-----被ACL丢弃,或审查后被丢弃,都不会去匹配全局policy-map
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。