<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Information Security, Privacy and Regulatory Compliance - Content Filtering</title>
    <link>http://keithpachulski.securitytactics.com/</link>
    <description>Keith A. Pachulski - http://keithpachulski.securitytactics.com</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.5.2 - http://www.s9y.org/</generator>
    <pubDate>Sun, 04 Apr 2010 01:27:33 GMT</pubDate>

    <image>
        <url>http://keithpachulski.securitytactics.com/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Information Security, Privacy and Regulatory Compliance - Content Filtering - Keith A. Pachulski - http://keithpachulski.securitytactics.com</title>
        <link>http://keithpachulski.securitytactics.com/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Squid as a Passive Web Content Filtering System</title>
    <link>http://keithpachulski.securitytactics.com/index.php?/archives/1-Squid-as-a-Passive-Web-Content-Filtering-System.html</link>
            <category>Content Filtering</category>
            <category>Intrusion Analysis</category>
            <category>Intrusion Detection</category>
    
    <comments>http://keithpachulski.securitytactics.com/index.php?/archives/1-Squid-as-a-Passive-Web-Content-Filtering-System.html#comments</comments>
    <wfw:comment>http://keithpachulski.securitytactics.com/wfwcomment.php?cid=1</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://keithpachulski.securitytactics.com/rss.php?version=2.0&amp;type=comments&amp;cid=1</wfw:commentRss>
    

    <author>nospam@example.com (Keith Pachulski)</author>
    <content:encoded>
    The goal here is simple, have a content filtering system in place that is transparent to the end users that will simply terminate their web browsing sessions when they attempt to access sites deemed as malicious or in violation of company policy, or home restrictions. This setup is based on CentOS 5.4 with Squid installed via yum and iptables along with a Cisco Router, though the WCCP configuration could easily be ported over to an ASA with WCCP support.&lt;br /&gt;
&lt;br /&gt;
At the time of this writing, GRE tunneling as needed in this setup is not supported on either OpenSolaris or Solaris 10.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;Configuring the Router for WCCP v2&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;? Connect to the device via console/ssh/telnet and enter into configuration mode&lt;br /&gt;o enable&lt;br /&gt;o conf t&lt;br /&gt;&lt;br /&gt;? Define ?interesting traffic? via an extended access list&lt;br /&gt;o ip access-list extended filter&lt;br /&gt;o permit tcp 192.168.1.0 0.0.0.255 any eq 80&lt;br /&gt;o exit&lt;br /&gt;&lt;br /&gt;? Enable WCCP v2 and apply the filter list to WCCP&lt;br /&gt;o ip wccp version 2&lt;br /&gt;o Once you enter this command, WCCP is enabled but doing a show run does not display this command in the configuration&lt;br /&gt;o ip wccp web-cache redirect-list filter&lt;br /&gt;o This command tells the router to forward all traffic to the Squid server once it has connected to the router/switch&lt;br /&gt;o On the outbound interface (the one connected to the internet feed) enter the following&lt;br /&gt;o Interface &lt;hw name&gt;&lt;br /&gt;o ip wccp web-cache redirect out&lt;br /&gt;? This command tells the router to redirect all outbound traffic as defined by the filter access list.&lt;br /&gt;o Write the configuration before moving onto the Squid server configuration&lt;br /&gt;o ctrl+z&lt;br /&gt;o wr mem&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Configuring the Squid Server for WCCP v2&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;By default Squid, if installed from an rpm which it should be, stores its configuration files in /etc/squid/.&lt;br /&gt;&lt;br /&gt;Before beginning the configuration of squid, backup the original configuration file by doing the following:&lt;br /&gt;&lt;br /&gt;? cd /etc/squid&lt;br /&gt;? cp squid.conf squid.conf.original&lt;br /&gt;o This command will rename the original squid.conf to squid.conf.original&lt;br /&gt;&lt;br /&gt;Create the new squid configuration file and insert the base configuration information for Squid to support WCCP v2 content filtering:&lt;br /&gt;&lt;br /&gt;? su&lt;br /&gt;o enter root password&lt;br /&gt;? cd /etc/squid&lt;br /&gt;? vi squid.conf&lt;br /&gt;? Hit the &#039;i&#039; key to enter into insert mode then paste in the following:&lt;br /&gt;&lt;br /&gt;#Enable transparent mode on the default Squid service port of 3128&lt;br /&gt;&lt;br /&gt;http_port 3128 transparent&lt;br /&gt;#Default stuff Squid needs to function&lt;br /&gt;icp_port 0&lt;br /&gt;hierarchy_stoplist cgi-bin ?&lt;br /&gt;acl QUERY urlpath_regex cgi-bin \?&lt;br /&gt;cache deny QUERY&lt;br /&gt;acl apache rep_header Server ^Apache&lt;br /&gt;broken_vary_encoding allow apache&lt;br /&gt;access_log /var/log/squid/access.log squid&lt;br /&gt;ftp_passive on&lt;br /&gt;refresh_pattern ^ftp:           1440    20%     10080&lt;br /&gt;refresh_pattern ^gopher:        1440    0%      1440&lt;br /&gt;refresh_pattern .               0       20%     4320&lt;br /&gt;client_lifetime 1 day&lt;br /&gt;acl all src 0.0.0.0/0.0.0.0&lt;br /&gt;acl manager proto cache_object&lt;br /&gt;acl localhost src 127.0.0.1/255.255.255.255&lt;br /&gt;acl to_localhost dst 127.0.0.0/8&lt;br /&gt;acl SSL_ports port 443 7004&lt;br /&gt;acl CONNECT method CONNECT&lt;br /&gt;http_access allow manager localhost&lt;br /&gt;http_access deny manager&lt;br /&gt;http_access deny !Safe_ports&lt;br /&gt;http_access deny CONNECT !SSL_ports&lt;br /&gt;&lt;br /&gt;#Define the networks to be filtered and the WCCP device which will be using the server&lt;br /&gt;#Define networks here, this MUST mirror the filter access-list created on the router/ASA&lt;br /&gt;acl our_networks src 192.168.1.0/24&lt;br /&gt;&lt;br /&gt;#Add the squid access list files here&lt;br /&gt;acl blocksites dstdomain &quot;/etc/squid/deniedsites.acl&quot;&lt;br /&gt;&lt;br /&gt;#Define how we deny the traffic matching the blocked sites list - Any web traffic matching the destination domains will generate a TCP reset to the client&lt;br /&gt;deny_info TCP_RESET blocksites&lt;br /&gt;http_access deny blocksites&lt;br /&gt;&lt;br /&gt;#Define traffic we will allow which has not been blocked by the previous&lt;br /&gt;http_access allow our_networks&lt;br /&gt;http_access allow localhost&lt;br /&gt;http_access deny all&lt;br /&gt;http_reply_access allow all&lt;br /&gt;icp_access allow all&lt;br /&gt;visible_hostname squid&lt;br /&gt;&lt;br /&gt;#Define WCCP router/switch information here&lt;br /&gt;wccp2_router 192.168.1.254&lt;br /&gt;wccp_version 4&lt;br /&gt;wccp2_rebuild_wait on&lt;br /&gt;wccp2_forwarding_method 1&lt;br /&gt;wccp2_return_method 1&lt;br /&gt;wccp2_assignment_method 1&lt;br /&gt;wccp2_service standard 0&lt;br /&gt;coredump_dir /var/spool/squid&lt;br /&gt;&lt;br /&gt;? Once this has been posted into the configuration file, hit escape then type :wq and hit enter ? this will write and exit from the file&lt;br /&gt;? Type exit and hit enter to leave the root account.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Configuring the CentOS Server for GRE Tunneling and traffic forwarding&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Load the ip_gre module, make sure you load the correct gre module for the current kernel loaded. If the kernel is updated you should remove and reload the updated module&lt;br /&gt;&lt;br /&gt;? insmod /lib/modules/2.6.18-164.11.1.el5/kernel/net/ipv4/ip_gre.ko&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Creating the GRE interface on the server&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;? NOTE: Be careful when manually creating the GRE interface, editing the wrong file or inserting incorrect characters into the interface configuration file may render the system useless.&lt;br /&gt;? su&lt;br /&gt;o Enter the root password&lt;br /&gt;? vi /etc/sysconfig/network-scripts/ifcfg-gre0&lt;br /&gt;o NOTE: This is an example of how the interface is configured, correct the following fields with the IP information reflecting the network where the device is being installed&lt;br /&gt;&lt;br /&gt;#The IP Address of the interface should be the same as the primary interface on the server&lt;br /&gt;DEVICE=gre0&lt;br /&gt;BOOTPROTO=static&lt;br /&gt;BROADCAST=192.168.1.255&lt;br /&gt;IPADDR=192.168.1.1&lt;br /&gt;NETMASK=255.255.255.0&lt;br /&gt;NETWORK=10.5.0.0&lt;br /&gt;ONBOOT=yes&lt;br /&gt;TYPE=Ethernet&lt;br /&gt;&lt;br /&gt;? Once this has been posted into the configuration file, hit escape then type :wq and hit enter ? this will write and exit from the file&lt;br /&gt;? Turn the interface up by typing the following&lt;br /&gt;? ifconfig gre0 up&lt;br /&gt;? Type exit and hit enter to leave the root account.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Enable IP Forwarding within the server operating system&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;? su&lt;br /&gt;o Enter the root password&lt;br /&gt;echo 1 &gt; /proc/sys/net/ipv4/ip_forward&lt;br /&gt;echo 0 &gt; /proc/sys/net/ipv4/conf/default/rp_filter&lt;br /&gt;echo 0 &gt; /proc/sys/net/ipv4/conf/all/rp_filter&lt;br /&gt;echo 0 &gt; /proc/sys/net/ipv4/conf/eth0/rp_filter&lt;br /&gt;echo 0 &gt; /proc/sys/net/ipv4/conf/lo/rp_filter&lt;br /&gt;echo 0 &gt; /proc/sys/net/ipv4/conf/gre0/rp_filter&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Creating the IP GRE Tunnel from the Squid Server to the WCCP router/switch&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;? su&lt;br /&gt;o Enter the root password&lt;br /&gt;? /usr/sbin/iptunnel add wccp mode gre remote 192.168.1.254 local 192.168.1.1 dev eth0&lt;br /&gt;o Note: correct the remote and local address to reflect the correct IP of the remote WCCP device and the local address of the Squid server.&lt;br /&gt;? vi /etc/rc.local&lt;br /&gt;o hit &#039;i&#039; to enter into insert mode and paste in the following&lt;br /&gt;o /usr/sbin/iptunnel add wccp mode gre remote 192.168.1.254 local 192.168.1.1 dev eth0&lt;br /&gt;? Once this has been posted into the configuration file, hit escape then type :wq and hit enter ? this will write and exit from the file&lt;br /&gt;? Type exit and hit enter to leave the root account.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Modifying the static iptables rule set and adding the port redirection&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;? su&lt;br /&gt;o Enter the root password&lt;br /&gt;? vi /etc/sysconfig/iptables&lt;br /&gt;o hit &#039;i&#039; to enter insert mode and add the following lines into the firewall configuration&lt;br /&gt;o -A RH-Firewall-1-INPUT -p gre -j ACCEPT&lt;br /&gt;o Allows GRE traffic to the Squid server&lt;br /&gt;o -A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 2048 -j ACCEPT&lt;br /&gt;o Allows WCCP traffic to the server&lt;br /&gt;o -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3128 -j ACCEPT&lt;br /&gt;o Allows traffic to the Squid service port&lt;br /&gt;? Once this has been posted into the configuration file, hit escape then type :wq and hit enter ? this will write and exit from the file&lt;br /&gt;? Type the following to enable port redirection for traffic coming into the GRE interface to the Squid service&lt;br /&gt;o /usr/bin/iptables -t nat -I PREROUTING -i gre0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128&lt;br /&gt;? vi /etc/rc.local&lt;br /&gt;o hit &#039;i&#039; to enter into insert mode and paste in the following&lt;br /&gt;o /usr/bin/iptables -t nat -I PREROUTING -i gre0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128&lt;br /&gt;? Once this has been posted into the configuration file, hit escape then type :wq and hit enter ? this will write and exit from the file&lt;br /&gt;? Type exit and hit enter to leave the root account.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Starting the Squid service and verifying WCCP connection from the Squid server to the router/switch&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;WCCP Router&lt;br /&gt;? Console/ssh to the WCCP router and enter the following commands&lt;br /&gt;o enable&lt;br /&gt;o conf t&lt;br /&gt;o logging on&lt;br /&gt;o logging monitor debug&lt;br /&gt;o exit&lt;br /&gt;o debug ip wccp event&lt;br /&gt;o debug ip wccp packets&lt;br /&gt;o terminal monitor&lt;br /&gt;Squid Server&lt;br /&gt;? Start the Squid service&lt;br /&gt;? su&lt;br /&gt;o Enter the root password&lt;br /&gt;? /etc/rc.d/init.d/squid start&lt;br /&gt;&lt;br /&gt;Once the squid service has started, you should start seeing messages on the router/switch saying new WCCP router detected and then a flurry of ?Here_I_Am? and ?I_See_You? messages on the console. Once you see these, the squid server has successfully connected to the WCCP service on the router/switch.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Populating the deniedsite.acl&lt;/u&gt;&lt;br /&gt;&lt;br /&gt;Sites that you want to deny access to should be added to the file mentioned previously in the configuration at /etc/squid/deniedsites.acl&lt;br /&gt;&lt;br /&gt;These should be added in same top-level structure as the user accessed the site. For example, the user goes to www.playboy.com - We want to deny access to the top level as well as all subdomains of .playboy.com so in the deniedsites.acl file we add the following:  
    </content:encoded>

    <pubDate>Tue, 09 Feb 2010 17:32:00 -0500</pubDate>
    <guid isPermaLink="false">http://keithpachulski.securitytactics.com/index.php?/archives/1-guid.html</guid>
    
</item>

</channel>
</rss>