lundi 3 septembre 2007
Squid3 et Iptables: interdire certains sites
Par david techer, lundi 3 septembre 2007 à 01:47 :: Linux

iptables -t nat -A PREROUTING -i eth0 -s 192.168.2.1/10 -p tcp --dport 80 -j DNAT --to-destination 192.168.2.1:3128 iptables -A FORWARD -p tcp -i eth0 --dport 3128 -j ACCEPTEnsuite pour squid3, il m'a suffit de faire le petit script suivant par exemple pour mon réseau en 192.168.2.X en interdisant les sites qui contiennent les mots busty ou pinupfiles
http_port 3128 transparent icp_port 3130 hierarchy_stoplist cgi-bin ? acl QUERY urlpath_regex cgi-bin \? cache deny QUERY refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern . 0 20% 4320 acl all src 0.0.0.0/0.0.0.0 acl manager proto cache_object acl localhost src 127.0.0.1/255.255.255.255 acl to_localhost dst 127.0.0.0/8 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports acl reseau_maison src 192.168.2.0/24 acl site_busty dstdom_regex -i ^.*busty.* acl site_pinup dstdom_regex -i ^.*pinupfiles.* http_access deny site_busty http_reply_access deny site_busty http_access deny site_pinup http_reply_acces deny site_pinup http_access allow reseau_maison http_access allow localhost http_reply_access allow all icp_access allow all coredump_dir /var/spool/squid3