ASA8.4policy-map接口和全局执行的优先级测试:-创新互联

一.概述:

成都一家集口碑和实力的网站建设服务商,拥有专业的企业建站团队和靠谱的建站技术,10年企业及个人网站建设经验 ,为成都超过千家客户提供网页设计制作,网站开发,企业网站制作建设等服务,包括成都营销型网站建设,品牌网站设计,同时也为不同行业的客户提供成都网站建设、成都网站设计的服务,包括成都电商型网站制作建设,装修行业网站制作建设,传统机械行业网站建设,传统农业行业网站制作建设。在成都做网站,选网站制作建设服务商就选创新互联。

  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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


当前文章:ASA8.4policy-map接口和全局执行的优先级测试:-创新互联
分享网址:http://scyanting.com/article/goggc.html