Block Access to Facebook on Cisco ASA with MPF (Modular Policy Framework)

AID: 1779
  • Status: Published

5850 points

  • ByPeteLong
  • TypeGeneral
  • Posted on2009-10-15 at 04:00:26
If you have an ASA5510 then this sort of thing would be better handled with a CSC Module, however on an ASA5505 thats not an option, and if you want to throw in a quick solution to stop your staff going to facebook during work time, then this is the best solution

NOTE: This can be used for any web site simply add each URL you want to block.

Log into your firewall and enter enable mode, then enter configure terminal mode.


Password:
Type help or '?' for a list of available commands.
PetesASA> en
Password: ********
PetesASA# conf t
PetesASA(config)#



1. The first thing we are going to do is write a "Regular Expression" that matches Facebook, (Repeat the line adding domainlist2, 3 etc for each additional domain you require to block.)


PetesASA(config)#
PetesASA(config)# regex domainlist1 "facebook.com"
PetesASA(config)#

 

2. Now we are going to create a "Class-map" which will include our regular expression. (Note: for additional you would simply add multiple match commands.)


PetesASA(config)#
PetesASA(config)# class-map type regex match-any DomainBlockList
PetesASA(config-cmap)# match regex domainlist1
PetesASA(config-cmap)#

 

3. We are now going to create a second class map, this one is for http inspection, and uses the first class map we created, it basically says, this class map is for http inspection and will inspect for what we declared in the first class map (i.e. Inspect http traffic for any instance of facebook.com).

 
PetesASA(config)#
PetesASA(config)# class-map type inspect http match-all BlockDomainsClass
PetesASA(config-cmap)# match request header host regex class DomainBlockList
PetesASA(config-cmap)#



4. Now to apply these class-maps we need to use a policy, the rule for policies is, you can have tons of policies but you can only apply one global policy, AND you can also have a policy for each interface, So here Ill create a policy for http inspection and use the classes we created above....

 
PetesASA(config)#
PetesASA(config)# policy-map type inspect http http_inspection_policy
PetesASA(config-pmap)# class BlockDomainsClass
PetesASA(config-pmap-c)# reset log
PetesASA(config-pmap-c)#



5. Then to knit everything together, I'm going to embed this policy in my firewalls global policy.

 
PetesASA(config)#
PetesASA(config)# policy-map global_policy
PetesASA(config-pmap)# class inspection_default
PetesASA(config-pmap-c)# inspect http http_inspection_policy
PetesASA(config-pmap-c)#

 

6. Note: Above I've assumed you have the default global policy, If you haven't, this will not apply until you have applied the global_policy globally, this is done with a service-policy command, check to see if you already have this command in your config, or simply execute the command and the firewall and will tell you, like so....

Note: If it does not error then it was NOT applied :)

 
PetesASA(config)#
PetesASA(config)# service-policy global_policy global
WARNING: Policy map global_policy is already configured as a service policy
PetesASA(config)#

 

7. Don't forget the save the config with a "write mem" command.
 
If you want to have this on a policy of its own, applied to an interface rather than on the Global Policy here is some working code to copy and paste
 

regex BLOCKED_DOMAIN_1 "www.facbook.com"
access-list TRAFFIC_TO_INSPECT_FOR_BLOCKED_DOMAINS extended permit tcp any any eq http
class-map type regex match-any CLASS_MAP_BLOCKED_DOMAIN_LIST
  match regex BLOCKED_DOMAIN_1
class-map type inspect http match-all CLASS_MAP_DEFINE_TRAFFIC_TO_INSPECT
  match request header host regex class CLASS_MAP_BLOCKED_DOMAIN_LIST
class-map CLASS_MAP_HTTP_TRAFFIC
  match access-list TRAFFIC_TO_INSPECT_FOR_BLOCKED_DOMAINS
policy-map type inspect http POLICY_MAP_HTTP_INSPECTION
  parameters
  class CLASS_MAP_DEFINE_TRAFFIC_TO_INSPECT
  drop-connection log
policy-map POLICY_MAP_OUTSIDE_INTERFACE
class CLASS_MAP_HTTP_TRAFFIC
  inspect http POLICY_MAP_HTTP_INSPECTION
service-policy POLICY_MAP_OUTSIDE_INTERFACE interface outside
Asked On
2009-10-15 at 04:00:26ID1779
Tags

Cisco ASA MPF

Topic

Cisco PIX Firewall

Views
7740

Comments

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Cisco PIX/ASA Experts

  1. erniebeek

    122,361

    Master

    0 points yesterday

    Profile
    Rank: Genius
  2. PeteLong

    64,083

    Master

    0 points yesterday

    Profile
    Rank: Genius
  3. fgasimzade

    54,292

    Master

    0 points yesterday

    Profile
    Rank: Wizard
  4. Kvistofta

    51,576

    Master

    0 points yesterday

    Profile
    Rank: Sage
  5. jmeggers

    37,798

    0 points yesterday

    Profile
    Rank: Sage
  6. nazsky

    36,832

    0 points yesterday

    Profile
    Rank: Wizard
  7. lruiz52

    33,783

    0 points yesterday

    Profile
    Rank: Guru
  8. MikeKane

    30,788

    0 points yesterday

    Profile
    Rank: Genius
  9. donjohnston

    29,020

    0 points yesterday

    Profile
    Rank: Genius
  10. lrmoore

    27,412

    0 points yesterday

    Profile
    Rank: Savant
  11. TimotiSt

    21,109

    0 points yesterday

    Profile
    Rank: Master
  12. The_Warlock

    20,300

    0 points yesterday

    Profile
    Rank: Wizard
  13. ArneLovius

    18,640

    0 points yesterday

    Profile
    Rank: Wizard
  14. henkva

    18,216

    0 points yesterday

    Profile
    Rank: Master
  15. ikalmar

    18,108

    10 points yesterday

    Profile
    Rank: Genius
  16. mat1458

    16,796

    0 points yesterday

    Profile
    Rank: Master
  17. harbor235

    16,375

    0 points yesterday

    Profile
    Rank: Genius
  18. jodylemoine

    16,300

    0 points yesterday

    Profile
    Rank: Sage
  19. eeRoot

    14,618

    0 points yesterday

    Profile
    Rank: Wizard
  20. max_the_king

    14,311

    0 points yesterday

    Profile
    Rank: Master
  21. kenboonejr

    14,220

    0 points yesterday

    Profile
    Rank: Sage
  22. Soulja

    14,100

    0 points yesterday

    Profile
    Rank: Genius
  23. craigbeck

    14,000

    0 points yesterday

    Profile
    Rank: Sage
  24. JZeolla

    13,975

    0 points yesterday

    Profile
  25. Netty

    12,436

    0 points yesterday

    Profile
    Rank: Guru

Hall Of Fame