<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>ardenpackeer.com &#187; Security</title>
	<atom:link href="http://ardenpackeer.com/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://ardenpackeer.com</link>
	<description>Becoming a Cisco CCIE Network Ninja</description>
	<pubDate>Tue, 21 Oct 2008 09:19:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Tutorial: Time-Based ACLS</title>
		<link>http://ardenpackeer.com/security/tutorial-time-based-acls/</link>
		<comments>http://ardenpackeer.com/security/tutorial-time-based-acls/#comments</comments>
		<pubDate>Tue, 20 May 2008 06:37:27 +0000</pubDate>
		<dc:creator>Arden Packeer, CCIE #20716</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[access list]]></category>

		<category><![CDATA[acls]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[proxy]]></category>

		<category><![CDATA[time-based acls]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://ardenpackeer.com/?p=119</guid>
		<description><![CDATA[Time based ACLS are useful when you want to restrict traffic based on time of day. For example, you might employ time based ACLs if you wanted to only allow web surfing during a particular time of day or allow access to a server during work hours. We will be exploring these scenarios in this tutorial.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cisco.com/en/US/products/sw/secursw/ps1018/products_tech_note09186a00800a5b9a.shtml#timebasedtimerange" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');">Time-based ACLs</a> are useful when you want to restrict traffic based on the time of day. For example, you might employ time-based ACLs if you wanted to only allow web surfing during a particular time of day or allow access to a particular server only during work hours. We will be exploring these scenarios in this tutorial.</p>
<h3 class="mast">Time-Based ACLs - Scenario 1:</h3>
<p>Let&#8217;s say you had the following requirement:</p>
<p style="padding-left: 30px;"><em>&#8220;Uses should only be allowed to access the Web Server located at the IP address of 192.168.1.254 during work hours. After work, users should not have access to this web server. All other traffic should be allowed.&#8221;</em></p>
<p>Seems simple enough. We will define work hours as Monday to Friday 9:00am to 5:00pm (you wish!). Most people when given this problem respond with this (or something similar):</p>
<pre><code>time-range WORK-HOURS
 periodic weekdays 9:00 to 17:00
!
ip access-list extend DENY-WEB
 permit tcp any host 192.168.1.254 eq www time-range WORK-HOURS
 permit ip any any
 </code></pre>
<p>We have defined a <a href="http://www.cisco.com/en/US/docs/ios/netmgmt/command/reference/nm_15.html#wp1012373" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');">time-range</a> called WORK-HOURS. WORK-HOURS is defined as including all times between 9am to 5pm Monday to Friday. Cool. Exactly what we want. We have then defined an access-list called DENY-WEB that matches tcp traffic destined to the host during the time-range WORK-HOURS. Everything else is permitted.</p>
<p>At first glance this looks fine, but it will not work. </p>
<p>Let&#8217;s examine why this will not work. Lets pretend it is Monday morning at 10am. The user hops on and points his browser to http://192.168.1.254. The first rule of the access list will be matched and then access is granted. Cool. This is the behaviour we want.</p>
<p>Now let&#8217;s pretend it is Monday night at 6pm. The same user hops on and points his browser to http://192.168.1.254. The first line of the access list will <em>not</em> be matched because it is not during the WORK-HOURS time range. All the conditions on the access-list line must be matched, <em>so we go to the next rule defined in the access-list.</em> We will match this rule (permit ip any any) and the traffic will also be <em>allowed</em>. This is obviously not what we want!</p>
<p><strong>Solution:</strong></p>
<pre><code>time-range WORK-HOURS
 periodic weekdays 9:00 to 17:00
!
ip access-list extend DENY-WEB
 permit tcp any host 192.168.1.254 eq www time-range WORK-HOURS
 <strong>deny tcp any host 192.168.1.254 eq www</strong>
 permit ip any any
 </code></pre>
<p>Much better. Now when the first rule is not matched, we will allow everything except for traffic destined for the web server. </p>
<h3 class="mast">Time-Based ACLs - Scenario 2:</h3>
<p>Let&#8217;s say we have a new requirement:</p>
<p style="padding-left: 30px;"><em>During work hours users must be able to access web sites <strong>only</strong> through a proxy server located at 192.168.1.254. The <a href="http://www.squid-cache.org/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.squid-cache.org');">proxy server</a> is listening on tcp port 3128. After work hours users should be granted full access to any IP address and any website. During work hours the only thing they should be able to access is the proxy server. Do not create two time-ranges for this.</em></p>
<p>Hmmm. Lets try this:</p>
<pre><code>time-range WORK-HOURS
periodic weekdays 9:00 to 17:00
!
ip access-list extend DENY-WEB
 permit tcp any host 192.168.1.254 eq 3128 time-range WORK-HOURS
 permit ip any any</code></pre>
<p>This is what most people that I presented this problem too responded with. This is incorrect. Lets have a look at a few use-cases to determine why. Lets pretend its Monday at 10am. The user tries to browse to cisco.com <em>directly</em> instead of going through a proxy server. The first rule of access list will not be matched. The time range is matched, but the destination address will be cisco.com not the address of the proxy server. The next rule will then be matched (permit ip any any). This will allow access to cisco.com during work hours without going through the proxy server which is not what we want. </p>
<p>We could try:</p>
<pre><code>time-range NON-WORK-HOURS
 periodic weekend 0:00 to 23:59
 periodic weekdays 0:00 to 8:59
 periodic weekdays 17:01 to 23:59
!
time-range WORK-HOURS
periodic weekdays 9:00 to 17:00
!
ip access-list extend DENY-WEB
 permit tcp any host 192.168.1.254 eq 3128 time-range WORK-HOURS
 permit ip any any time-range NON-WORK-HOURS</code></pre>
<p>This will work. On Monday at 9:30am, a user tries to access cisco.com <em>directly</em> instead of going through a proxy server. As per the requirement, this shouldn&#8217;t be allowed. The first rule of the access-list will <em>not</em> be matched. The time range is matched, but the destination address will be cisco.com not the address of the proxy server. </p>
<p>The second rule will also <em>not</em> be matched as it does not match the time-range NON-WORK-HOURS (ie. its during work time). The packet will be dropped which is exactly what we want to happen. Unfortunately, this will not meet the requirement of &#8220;Do not create two time-ranges for this&#8221;. DAMN! So how do we do this?</p>
<p><strong>Solution:</strong></p>
<pre><code>time-range NON-WORK-HOURS
 periodic weekend 0:00 to 23:59
 periodic weekdays 0:00 to 8:59
 periodic weekdays 17:01 to 23:59
!
ip access-list extend DENY_WEB
 permit ip any any time-range NON-WORK-HOURS
 permit tcp any host 192.168.1.254 eq 3128</code></pre>
<p>We have an access list that matches IP traffic only for the time-range NON-WORK-HOURS. During work hours we can only access the proxy server at 192.168.1.254 on tcp port 3128 Everything else will be blocked. Awesome, just what we wanted!</p>
<p>HTH! :)</p>
<p>Read this article and more like it on <a href="http://ardenpackeer.com" >ardenpackeer.com</a>
<br>
Follow me on twitter: <a href="http://twitter.com/ardenpackeer" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');">http://twitter.com/ardenpackeer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ardenpackeer.com/security/tutorial-time-based-acls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Security: Common Ethertypes in Vlan Access Maps</title>
		<link>http://ardenpackeer.com/security/security-common-ethertypes-in-vlan-access-maps/</link>
		<comments>http://ardenpackeer.com/security/security-common-ethertypes-in-vlan-access-maps/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 22:49:12 +0000</pubDate>
		<dc:creator>Arden Packeer, CCIE #20716</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[arp]]></category>

		<category><![CDATA[BPDU]]></category>

		<category><![CDATA[ethertypes]]></category>

		<category><![CDATA[ISL]]></category>

		<category><![CDATA[mac access-list]]></category>

		<category><![CDATA[PVST]]></category>

		<category><![CDATA[SNAP]]></category>

		<category><![CDATA[vlan]]></category>

		<category><![CDATA[vlan access-map]]></category>

		<guid isPermaLink="false">http://ardenpackeer.com/blog/security-common-ethertypes-in-vlan-access-maps/</guid>
		<description><![CDATA[I was putting together my study notes on Vlan Access Maps and all the common ethertypes that I was asked to match in all the labs that I have done. I was trying to figure out how to match spanning tree BPDU's when they are transported in Ethernet frames, and was having real difficulty locating this on the Cisco DOC CD.....
]]></description>
			<content:encoded><![CDATA[<p>I was putting together my study notes on Vlan Access Maps and all the common ethertypes that I was asked to match in all the labs that I have done. I was trying to figure out how to match spanning tree BPDU&#8217;s when they are transported in Ethernet frames, and was having real difficulty locating this on the Cisco DOC CD. </p>
<p>I eventually found <a href="http://forum.internetworkexpert.com/ubbthreads.php/ubb/showflat/Number/10471" onclick="javascript:pageTracker._trackPageview('/outbound/article/forum.internetworkexpert.com');">this by Petr Lapukhov CCIE#16379 on the Internetwork Expert CCIE Forums</a>:</p>
<p><em>1) Cisco runs IEEE STP over non-trunking links, i.e. access-ports.<br />
IEEE STP utilizes 802.3 LLC ethernet frame format and multicast<br />
address 0180.c200.0000 BPDU frames have LSAP values of 0&#215;42 for<br />
SSAP/DSAP</p>
<p>2) Cisco runs PVST over ISL trunks. Basically, this is just a<br />
classic IEEE STP BPDU, send with VLAN tag, and LSAP value 0&#215;42<br />
Nothing to worry about here</p>
<p>3) Cisco runs PVST+ over 802.1q trunks. Now it sends IEEE STP<br />
over VLAN 1, and dublicates it to PVST+ multicast address, with<br />
PVST+ (SSTP) encapsulation. At the same time, it sends PVST+ BPDUs,<br />
over every non-native VLAN, tagged with 802.1q VLAN tag. PVST+<br />
encapsulation is 802.3 SNAP frame (OUI/Type &#8220;0&#215;00 0&#215;00 0&#215;0c / 0&#215;01 0&#215;0b&#8221;).<br />
This procedure is essentially a tunneling of PVST over 802.1q IEEE cloud.</p>
<p>If 802.1q VLAN1 is not native, procedure is a bit different, but still<br />
Cisco sends a mix of IEEE and PVST+ BPDUs, with IEEE sent untagged.</p>
<p>Now the lesson is that you should watch for 802.1q with Cisco With<br />
ISL things run smoothly, you have IEEE STP frames on every VLAN. With<br />
802.1q you got that horrible mix </em></p>
<p>So, putting all that together I came up with this:</p>
<pre>
<code>mac access-list extended IP
 permit any any 0x800 0x0</code>
</pre>
<pre>
<code>mac access-list extended IPV6
 permit any any 0x86DD 0x0</code>
</pre>
<pre>
<code>mac access-list extended IP_ARP
 permit any any 0x806 0x0</code>
</pre>
<pre>
<code>mac access-list extended PVST+
 permit any any lsap 0xAAAA 0x0
!
! PVST+ uses LLC SNAP encapsulation LSAP equal 0xAAAA.
! In this case need to we see more deeply OUI/Type part SNAP header.
! But i don't know how it can be matched in Cisco IOS.</code>
</pre>
<pre>
<code>mac access-list extended IEEE_STP
 permit any any lsap 0x4242 0x0</code>
</pre>
<pre>
<code>mac access-list extended ISL_PVST
 permit any any lsap 0x4242 0x0
!
! ie. sames as IEEE_STP!</code>
</pre>
<p>You can use this vlan access-maps in conjunction with these mac access-lists to allow or deny only certain traffic through a vlan. </p>
<p>For example to allow IP and ARP only in vlan 10:</p>
<pre>
<code>!
! Be careful we are technically blocking Spanning-tree BPDU's, so this might cause loops!
!
ip access-list extended IP
 permit ip any any
!
mac access-list extended IP_ARP
 permit any any 0x806 0x0
!
vlan access-map IP_AND_ARP_ONLY 10
 action forward
 match ip address IP
!
vlan access-map IP_AND_ARP_ONLY 20
 action forward
 match mac address IP_ARP
!
vlan access-map IP_AND_ARP_ONLY 30
 action drop
!
vlan filter IP_AND_ARP_ONLY vlan-list 10</code>
</pre>
<p>In the example above we are using an ip access-list to match ip traffic. I originally thought that we could have also used a mac access-list to do this, but an astute reader (See comments below&#8230;thanks Sharath!) pointed out this is not possible. I hope this helps. Now back to labs! :)</p>
<h3 class="mast">Resources:</h3>
<ul>
<li>The Ethertypes can be found here on Cisco Doc CD<a href="http://www.cisco.com/en/US/docs/ios/12_2/ibm/vol1/command/reference/br1fethc.html#wp1017386" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');"> (Cisco IOS Bridging and IBM Networking Command Reference -> Appendix)</a>.</li>
<li><a href="http://cisco.iphelp.ru/faq/35/0032.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/cisco.iphelp.ru');">Sniffing For Cisco Specific Protocols</a></li>
<li><a href="http://ccie-in-3-months.blogspot.com/2008/01/how-to-deny-arp-traffic-between-two.html" onclick="javascript:pageTracker._trackPageview('/outbound/article/ccie-in-3-months.blogspot.com');">How to permit ARP traffic between only two hosts - CCIE-IN-3-MONTHS</a></li>
</ul>
<p>Read this article and more like it on <a href="http://ardenpackeer.com" >ardenpackeer.com</a>
<br>
Follow me on twitter: <a href="http://twitter.com/ardenpackeer" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');">http://twitter.com/ardenpackeer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ardenpackeer.com/security/security-common-ethertypes-in-vlan-access-maps/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tutorial: How to use Cisco MQC &#038; NBAR to filter websites like Youtube</title>
		<link>http://ardenpackeer.com/qos-voip/tutorial-how-to-use-cisco-mqc-nbar-to-filter-websites-like-youtube/</link>
		<comments>http://ardenpackeer.com/qos-voip/tutorial-how-to-use-cisco-mqc-nbar-to-filter-websites-like-youtube/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 01:32:47 +0000</pubDate>
		<dc:creator>Arden Packeer, CCIE #20716</dc:creator>
		
		<category><![CDATA[Featured]]></category>

		<category><![CDATA[Featured Articles]]></category>

		<category><![CDATA[IOS Features &amp; Management]]></category>

		<category><![CDATA[QoS &amp; VoIP]]></category>

		<category><![CDATA[Security]]></category>

		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[dynagen]]></category>

		<category><![CDATA[dynamips]]></category>

		<category><![CDATA[filtering]]></category>

		<category><![CDATA[flash]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[mime]]></category>

		<category><![CDATA[mqc]]></category>

		<category><![CDATA[nbar]]></category>

		<category><![CDATA[qos]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://ardenpackeer.com/qos-voip/tutorial-how-to-use-cisco-mqc-nbar-to-filter-websites-like-youtube/</guid>
		<description><![CDATA[I was asked a great question by one of my clients regarding filtering of websites. He had filtered youtube and google video at his proxy server but with the number of different video sites popping up (metacafe, jibjab etc etc), his filters just couldn&#8217;t keep up&#8230;and neither could his bandwidth!
One solution to this problem is [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked a great question by one of my clients regarding filtering of websites. He had filtered <a href="http://www.youtube.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.youtube.com');">youtube</a> and <a href="http://video.google.com.au/" onclick="javascript:pageTracker._trackPageview('/outbound/article/video.google.com.au');">google video</a> at his proxy server but with the number of different video sites popping up (metacafe, jibjab etc etc), his filters just couldn&#8217;t keep up&#8230;and neither could his bandwidth!</p>
<p>One solution to this problem is the use of Cisco&#8217;s Network Based Application Recognition (NBAR). NBAR is a deep packet inspection and classification engine. It was first introduced in experimental versions of IOS v12.1 and can be used with Cisco&#8217;s <a href="http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124cg/hqos_c/part40/qctmcli2.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');">Modular Quality Of Service Command Line (MQC)</a>.</p>
<p>In this article we will look at using MQC to filter websites. I will demonstrate using the <a href="http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124cr/hqos_r/qos_m1h.htm#wp1128712" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');">match protocol http</a> command to match a URL, a host or MIME type. We will use the following topology for demonstration:</p>
<div class="captionfull"><img src="http://ardenpackeer.com/wp-content/uploads/2007/12/topology1.gif" alt="Network Topology - Webserver" /></div>
<p>R3 will act as a webserver and R1 as a client. The filtering will be applied on R2. You can download the dynamips .net file the following topology <a href="http://ardenpackeer.com/wp-content/uploads/2007/12/webserver.net" >here</a>.<br />
R1 Base Configuration:</p>
<pre>
<code>hostname R1
!
int s1/0
 ip add 10.0.12.1 255.255.255.0
 no shut
!
router ospf 1
 network 10.0.12.1 0.0.0.0 area 0</code></pre>
<p>R2 Base Configuration:</p>
<pre>
<code>hostname R2
!
int s1/0
 ip add 10.0.12.2 255.255.255.0
 no shut
!
int s1/1
 ip add 10.0.23.2 255.255.255.0
 no shut
!
router ospf 1
 network 10.0.12.2 0.0.0.0 area 0
 network 10.0.23.2 0.0.0.0 area 0</code></pre>
<p>R3 Base Configuration:</p>
<pre>
<code>hostname R3
!
int s1/0
 ip add 10.0.23.3 255.255.255.0
 no shut
!
int f0/0
 ip add 192.168.1.100 255.255.255.0
 no shut
!
router ospf 1
 network 10.0.23.3 0.0.0.0 area 0
!
ip http server
ip http path flash:</code></pre>
<p>We have set up R3 as a webserver. Details on how to setup R3 as a webserver using IOS can be found <a href="http://ardenpackeer.com/ios-features-management/how-to-set-up-a-cisco-router-as-a-webserver/" >here</a>.</p>
<pre>
<code>R3#sh run | in ip http
ip http server
no ip http secure-server
ip http path flash:</code></pre>
<pre>
<code>R3#dir
Directory of flash:/

    1  -rw-          90                    &lt;no&gt;  picture.gif
    2  -rw-         329                    &lt;no&gt;  picture.jpg
    3  -rw-         174                    &lt;no&gt;  index.html

8388604 bytes total (8387812 bytes free)
&lt;/no&gt;&lt;/no&gt;&lt;/no&gt;</code></pre>
<p><strong>Basic HTTP Filtering using NBAR</strong></p>
<p>Lets set up basic http filtering with MQC on R2.</p>
<pre>
<code>R2(config)#class-map match-all MATCH-HTTP
R2(config-cmap)#match protocol http
R2(config-cmap)#exit
R2(config)#policy-map HTTP-POLICY
R2(config-pmap)#class MATCH-HTTP
R2(config-pmap-c)#set dscp af13
R2(config-pmap-c)#exit
R2(config-pmap)#int s1/0
R2(config-if)#service-policy input HTTP-POLICY</code></pre>
<p>In the code above we have a class map called MATCH-HTTP. The match protocol http command tells NBAR to match the http protocol. This will match all http traffic. The MATCH-HTTP class is then utilized in the HTTP-POLICY policy map. This policy map is used to set a DSCP marking on all traffic that matches the MATCH-HTTP class (ie all http traffic). The policy is then implemented on R2&#8217;s s1/0. Traffic is inspected and marked as it comes into that interface.</p>
<p>We can check how many packets have been marked using the show policy-map command.</p>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      2 packets, 168 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any
R2#</code></pre>
<p>Lets generate some http traffic, and see if our policy marks some packets.</p>
<pre>
<code>R1#copy http://10.0.23.3/index.html null:
Loading http://10.0.23.3/index.html
174 bytes copied in 0.544 secs (320 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      5 packets, 344 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http
      QoS Set
        dscp af13
          Packets marked 5

    Class-map: class-default (match-any)
      124 packets, 10340 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>We used the <strong>copy http://10.0.23.3/index.html null:</strong> command to generate some http traffic. We can see above that 5 packets were generated and were marked as af13. All other traffic will fall into the class-default class. With the packets marked, we could forward them or drop them.</p>
<p>Instead of matching all of the http protocol we can use NBAR to look further into the packet and classify or drop packets based on the host requested.</p>
<p><strong>Match protocol HTTP host</strong></p>
<p>The match protocol HTTP url command is used to match a url. It takes a regular expression as an argument. For example:</p>
<pre>
<code>match protocol http host *youtube.com*
! This would match anything in youtube.com like http://www.youtube.com or http://video.youtube.com
!
match protocol http host *google*
! This would match anything with google in the host like http://mail.google.com or
http://www.google.com.au
!
match protocol http host google*
! This would match http://google.com but not http://video.google.com</code></pre>
<p>Lets set up R2 to filter based on a host.</p>
<pre>
<code>R2(config)#class-map MATCH-HTTP
R2(config-cmap)#no match protocol http
R2(config-cmap)#match protocol http host 10.0.23.3</code></pre>
<pre>
<code>R2#clear counters s1/0
Clear "show interface" counters on this interface [confirm]
*Mar  1 00:04:42.071: %CLEAR-5-COUNTERS: Clear counter on interface Serial1/0 by console
R2#
R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http host "10.0.23.3"
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      1 packets, 84 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>We&#8217;ve cleared the counters on R2, so lets generate some traffic on R1 again.</p>
<pre>
<code>R1#copy http://10.0.23.3/index.html null:
Loading http://10.0.23.3/index.html
174 bytes copied in 0.596 secs (292 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      5 packets, 344 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http host "10.0.23.3"
      QoS Set
        dscp af13
          Packets marked 5

    Class-map: class-default (match-any)
      64 packets, 5300 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>We can see here it matched 5 packets based on the host. We can use this to match whole sites like youtube.com or video.google.com.</p>
<p><strong>Match protocol HTTP url</strong></p>
<p>We can match strings AFTER the host portion of a URL using the match protocol http url command. It also takes a regular expression as an argument. For example:</p>
<pre>
<code>match protocol http url *video*
! This would match http://www.cisco.com/video/index.php or
http://www.google.com/stuff/video.html
!
match protocol http url video*
! This would match http://www.cisco.com/video but not http://www.cisco.com/stuff/video.html
! because stuff precedes the video portion of the url and in the expression above we have said
! it has to start with the string video
!
match protocol http url *.jpeg|*.jpg|*.gif
! This would match any .jpeg or .jpg or .gif extention in the url</code></pre>
<p>Lets set up R2 to match based on a URL.</p>
<pre>
<code>R2(config)#class-map MATCH-HTTP
R2(config-cmap)#no match protocol http host 10.0.23.3
R2(config-cmap)#match protocol http url *.jpg</code></pre>
<p>As you can see above we have used the match protocol http url function of NBAR to match any url that ends in a .jpg. This effectively blocks jpeg images (unless they have a different extension).</p>
<p>Let test it, before we send some traffic we&#8217;ll reset the counters on the interface.</p>
<pre>
<code>R2#clear counters s1/0
Clear "show interface" counters on this interface [confirm]
*Mar  1 00:43:39.135: %CLEAR-5-COUNTERS: Clear counter on interface Serial1/0 by console
R2#
R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http url "*.jpg"
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      1 packets, 84 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>If we request a gif file we <strong>shouldn&#8217;t</strong> match the class MATCH-HTTP. Lets test that first.</p>
<pre>
<code>R1#copy http://10.0.23.3/picture.gif null:
Loading http://10.0.23.3/picture.gif
90 bytes copied in 0.644 secs (140 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http url "*.jpg"
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      18 packets, 1209 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>Great Success! Looks pretty good. Now lets try a .jpg extension. We <strong>should</strong> match this.</p>
<pre>
<code>R1#copy http://10.0.23.3/picture.jpg null:
Loading http://10.0.23.3/picture.jpg
329 bytes copied in 0.820 secs (401 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      7 packets, 433 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http url "*.jpg"
      QoS Set
        dscp af13
          Packets marked 7

    Class-map: class-default (match-any)
      22 packets, 1469 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>Awesome! You can see above we matched based on a URL.</p>
<p><strong>match protocol http mime</strong></p>
<p>We can also use the match protocol http mime to match internet mime types. The mime type has to be the same mime type that the web server responds with. For a list of valid mime types check out: <a href="http://www.sfsu.edu/training/mimetype.htm" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.sfsu.edu');">http://www.sfsu.edu/training/mimetype.htm</a>. Lets look at an example:</p>
<pre>
<code>match protocol http mime image/jpeg
! This would match jpeg,jpg,jpe,jfif,pjpeg, and pjp types
!
match protocol http mime image/jpg
! This would not match anything as it is not a proper mime type. Get a list of the mime types
! here: http://www.sfsu.edu/training/mimetype.htm
!
match protocol http mime image*
! This would match all image mime types
!
match protocol http mime application/x-shockwave-flash
! This would not only match swf flash movies, but all of flash.</code></pre>
<p>Lets set up R2 to filter the image/jpeg mime type:</p>
<pre>
<code>R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#class-map MATCH-HTTP
R2(config-cmap)#no match protocol http url *.jpg
R2(config-cmap)#match protocol http mime ?
  WORD  Enter a string as the sub-protocol parameter

R2(config-cmap)#match protocol http mime image/jpeg
R2(config-cmap)#exit
R2(config)#exit</code></pre>
<p>Once again, we&#8217;ll clear the counters so we can verify that this works correctly.</p>
<pre>
<code>R2#clear counters s1/0
Clear "show interface" counters on this interface [confirm]
*Mar  1 01:12:10.759: %CLEAR-5-COUNTERS: Clear counter on interface Serial1/0 

R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http mime "image/jpeg"
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      1 packets, 84 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>On R1 lets generate some traffic. A gif file will be requested first. This <strong>should not</strong> match our policy.</p>
<pre>
<code>R1#copy http://10.0.23.3/picture.gif null:
Loading http://10.0.23.3/picture.gif
90 bytes copied in 0.808 secs (111 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http mime "image/jpeg"
      QoS Set
        dscp af13
          Packets marked 0

    Class-map: class-default (match-any)
      10 packets, 689 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>All good! Ok lets do the final test and actually request a jpeg image and see if it matches our policy.</p>
<pre>
<code>R1#copy http://10.0.23.3/picture.jpg null:
Loading http://10.0.23.3/picture.jpg
329 bytes copied in 1.216 secs (271 bytes/sec)</code></pre>
<pre>
<code>R2#sh policy-map int s1/0
 Serial1/0 

  Service-policy input: HTTP-POLICY

    Class-map: MATCH-HTTP (match-all)
      5 packets, 220 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: protocol http mime "image/jpeg"
      QoS Set
        dscp af13
          Packets marked 5

    Class-map: class-default (match-any)
      16 packets, 1162 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any</code></pre>
<p>You can see above that the jpeg image was matched. It works!</p>
<p><strong>Putting it all together</strong></p>
<p>So lets put it all together. We can use all three match protocol http commands in a match-any class map. For example:</p>
<pre>
<code>class-map match-any INTERNET-SCUM
 match protocol http host *youtube.com*|*video.google.com*
 match protocol http mime video/flv|video/x-flv|video/mp4|video/x-m4v|audio/mp4a-latm
 match protocol http mime video/3gpp|video/quicktime
 match protocol http url *.flv|*.mp4|*.m4v|*.m4a|*.3gp|*.mov
! uncomment below if you don't want ANY flash.
! match protocol http mime application/x-shockwave-flash
! match protocol http url *.swf
!
policy-map NOINTERNETVIDEO
 class INTERNET-SCUM
  drop
!
int s1/0
 service-policy input NOINTERNETVIDEO
!</code></pre>
<p>This would match any traffic going to youtube or video.google.com, or any flash applications, or common video mime types, and any swf (flash or flash movie) files! Be aware that NBAR does make your router take a hit in CPU processor usage, I&#8217;d suggest evaluating your processor usage before using this in production.</p>
<p>HTH! Now back to labs!</p>
<p><strong>Summary:</strong></p>
<ul>
<li>Use the <a href="http://www.cisco.com/univercd/cc/td/doc/product/software/ios124/124cr/hqos_r/qos_m1h.htm#wp1128712" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cisco.com');">match http protocol</a> command to match the http protocol.</li>
<li>match protocol http host matches the host portion</li>
<li>match protocol http url matches the url after the hostname</li>
<li>match protocol http mime matches mime types</li>
</ul>
<p><strong>Resources</strong><br />
<a href="http://ardenpackeer.com/wp-content/uploads/2007/12/webserver.net"  title="Webserver - Dynamips .net configuration file">Webserver - Dynamips .net configuration file</a><br />
<a href="http://ardenpackeer.com/wp-content/uploads/2007/12/qoshttp-r1.txt"  title="QOS HTTP Filtering - R1 Final Configuration">QOS HTTP Filtering - R1 Final Configuration</a><br />
<a href="http://ardenpackeer.com/wp-content/uploads/2007/12/qoshttp-r2.txt"  title="QOS HTTP Filtering - R2 Final Configuration">QOS HTTP Filtering - R2 Final Configuration</a><br />
<a href="http://ardenpackeer.com/wp-content/uploads/2007/12/qoshttp-r3.txt"  title="QOS HTTP Filtering - R3 Final Configuration">QOS HTTP Filtering - R3 Final Configuration</a></p>
<p>Read this article and more like it on <a href="http://ardenpackeer.com" >ardenpackeer.com</a>
<br>
Follow me on twitter: <a href="http://twitter.com/ardenpackeer" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');">http://twitter.com/ardenpackeer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ardenpackeer.com/qos-voip/tutorial-how-to-use-cisco-mqc-nbar-to-filter-websites-like-youtube/feed/</wfw:commentRss>
		</item>
		<item>
		<title>VLAN Access Lists</title>
		<link>http://ardenpackeer.com/security/vlan-access-lists/</link>
		<comments>http://ardenpackeer.com/security/vlan-access-lists/#comments</comments>
		<pubDate>Wed, 13 Jun 2007 04:15:25 +0000</pubDate>
		<dc:creator>Arden Packeer, CCIE #20716</dc:creator>
		
		<category><![CDATA[Security]]></category>

		<category><![CDATA[access list]]></category>

		<category><![CDATA[vlan]]></category>

		<guid isPermaLink="false">http://ardenpackeer.com/?p=13</guid>
		<description><![CDATA[I read this over on group study, which i thought was a really good example of how of why in the CCIE lab we should try and deny the traffic you don&#8217;t want and permit the rest. You will probably run into a lot less trouble. This goes against the usual security advice of permit [...]]]></description>
			<content:encoded><![CDATA[<p>I read this over on <a href="http://www.groupstudy.com/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.groupstudy.com');" target="_blank">group study</a>, which i thought was a really good example of how of why in the CCIE lab we should try and deny the traffic you don&#8217;t want and permit the rest. You will probably run into a lot less trouble. This goes against the usual security advice of permit what you want and deny everything else. This is the Cisco CCIE lab, it&#8217;s not meant to be a collection of best practices (quite the contrary sometimes!)</p>
<p>Anyway,  the problem was this: assume you are trying to prohibit DHCP within a given VLAN.</p>
<p>We could configure it with:</p>
<pre><code>access-list 101 permit udp any eq bootpc any eq bootps
vlan access-map test1 10
 action drop
 match ip address 101
vlan access-map test1 20
 action forward
vlan filter test1 vlan-list 11</code></pre>
<p>This will work by first dropping what we don&#8217;t want and permitting everything else. But if we reverse the logic (ie permit IP traffic, then deny the bootp) with:</p>
<pre><code>access-list 102 deny   udp any eq bootpc any eq bootps
access-list 102 permit ip any any
vlan access-map test2 10
 action forward
 match ip address 102
vlan access-map test2 20
 action drop
vlan filter test2 vlan-list 12</code></pre>
<p>This will <strong>not</strong> work. Why? It seems logical. But what about ARP? Arp traffic will be matched by the second part of the vlan access-map (ethertype 0&#215;806), so unless we have some static arp statements or they have been cached, we are in trouble.</p>
<p>Great example of vlan-access map logic.</p>
<p>Read this article and more like it on <a href="http://ardenpackeer.com" >ardenpackeer.com</a>
<br>
Follow me on twitter: <a href="http://twitter.com/ardenpackeer" onclick="javascript:pageTracker._trackPageview('/outbound/article/twitter.com');">http://twitter.com/ardenpackeer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ardenpackeer.com/security/vlan-access-lists/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
