Você está na página 1de 6

Taller SQUID

Access Control Lists You can limit users' ability to browse the Internet with access control lists (ACLs). Each ACL line defines a particular type of activity, such as an access time or source network, they are then linked to an http_access statement that tells Squid whether or not to deny or allow traffic that matches the ACL. Squid matches each Web access request it receives by checking the http_access list from top to bottom. If it finds a match, it enforces the allow or deny statement and stops reading further. You have to be careful not to place a deny statement in the list that blocks a similar allow statement below it. The final http_access statement denies everything, so it is best to place new http_access statements above it Note: The very last http_access statement in the squid.conf file denies all access. You therefore have to add your specific permit statements above this line. In the chapter's examples, I've suggested that you place your statements at the top of the http_access list for the sake of manageability, but you can put them anywhere in the section above that last line. Squid has a minimum required set of ACL statements in the ACCESS_CONTROL section of the squid.conf file. It is best to put new customized entries right after this list to make the file easier to read. Restricting Web Access By Time You can create access control lists with time parameters. For example, you can allow only business hour access from the home network. # # Add this to the bottom of the ACL section of squid.conf # acl home_network src 172.16.2.0/24 acl business_hours time M T W H F 9:00-17:00 # # Add this at the top of the http_access section of squid.conf # http_access allow home_network business_hours Or, you can allow morning access only: # # Add this to the bottom of the ACL section of squid.conf # acl mornings time 08:00-12:00 # # Add this at the top of the http_access section of squid.conf # http_access allow mornings

Restricting Web Access By IP Address You can create an access control list that restricts Web access to users on certain networks. In this case, it's an ACL that defines a home network of 192.168.1.0. # # Add this to the bottom of the ACL section of squid.conf # acl home_network src 192.168.1.0/255.255.255.0 You also have to add a corresponding http_access statement that allows traffic that matches the ACL: # # Add this at the top of the http_access section of squid.conf # http_access allow home_network Forcing Users To Use Your Squid Server If you are using access controls on Squid, you may also want to configure your firewall to allow only HTTP Internet access to only the Squid server. This forces your users to browse the Web through the Squid proxy. Making Your Squid Server Transparent To Users It is possible to limit HTTP Internet access to only the Squid server without having to modify the browser settings on your client PCs. This called a transparent proxy configuration. It is usually achieved by configuring a firewall between the client PCs and the Internet to redirect all HTTP (TCP port 80) traffic to the Squid server on TCP port 3128, which is the Squid server's default TCP port. iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 \ -j REDIRECT --to-port 3128

Listas de acceso basadas en archivos # Listas que definen conjuntos de maquinas acl redlocal src "/etc/squid/redlocal" acl privilegiados src "/etc/squid/privilegiados" acl restringidos src "/etc/squid/restringidos" acl administrador src 192.168.1.254 # Listas que definen palabras contenidas en un URL acl porno url_regex "/etc/squid/porno" # Contenido: # # sex # porn # girl # celebrit # extasis # drug # playboy # hustler # Lista de sitios inocentes que accidentealmente sean bloqueados acl noporno url_regex "/etc/squid/noporno" # Contenido: # # missingheart # wirelessexcite # msexchange # msexcel # freetown # geek-girls # adulteducation # Listas que definen tipos de extensiones # Define uan lista estricta de extensiones prohibidas acl multimedia urlpath_regex "/etc/squid/multimedia" # Contenido: # # \.mp3$ # \.avi$ # \.mov$ # \.mpg$ # \.bat$ # \.pif$ # \.sys$ # \.lnk$

# \.scr$ # \.exe$ # Define una lista moderada de extensiones prohibidas acl peligrosos urlpath_regex "/etc/squid/peligrosos" # Contenido: # # \.bat$ # \.pif$ # \.sys$ # \.lnk$ # \.scr$ # \.exe$ # Define una sola extensin acl realmedia urlpath_regex \.rm$ # Reglas de control de acceso # Regla por defecto: http_access allow localhost # Ejemplos de reglas de control de acceso http_access allow restringidos password !porno !multimedia http_access allow redlocal password !porno !peligrosos http_access allow privilegiados password !peligrosos http_access allow administrador http_access allow noporno all # Regla por defecto: http_access deny all Paso final: Acceso a SQUID, con contraseas Creacin del fichero de contraseas. Se requerir la creacin previa de un fichero que contendr los nombres de usuarios y sus correspondientes contraseas (cifradas). El fichero puede localizarse en cualquier lugar del sistema, con la nica condicin que sea asequible para el usuario squid. Debe procederse a crear un fichero /etc/squid/squid-passwd: touch /etc/squid/squid-passwd Como medida de seguridad, este fichero debe hacerse leble y escribible solo para el usuario squid:

chmod 600 /etc/squid/squid-passwd chown squid:squid /etc/squid/squid-passwd A continuacin deberemos dar de alta las cuentas que sean necesarias, utilizando el comando htpasswd -mismo que viene incluido en el paquete apache-1.3.22-. Ejemplo: htpasswd /etc/squid/squid-passwd joseperez Lo anterior solicitar teclear una nueva contrasea para el usuario joseperez y confirmar tecleando sta de nuevo. Repita con el resto de las cuentas que requiera dar de alta. Todas las cuentas que se den de alta de este modo son independientes a las ya existentes en el sistema. Al dar de alta una cuenta o cambiar una contrasea lo estar haciendo EXCLUSIVAMENTE para el acceso al servidor Proxy. Las cuentas son independientes a las que se tengan existentes en el sistema como seran shell, correo y Samba. Parmetros en /etc/squid/squid.conf Lo primero ser especificar que programa de autenticacin se utilizar. Localice la seccin que corresponde a la etiqueta authenticate_program. Por defecto no est especificado programa alguno. Considerando que ncsa_auth se localiza en /usr/lib/squid/ncsa_auth, procederemos a aadir el siguiente parmetro: authenticate_program /usr/lib/squid/ncsa_auth /etc/squid/squid-passwd /usr/lib/squid/ncsa_auth corresponde a la localizacin de el programa para autenticar y /etc/squid/squid-passwd al fichero que contiene las cuentas y sus contraseas. El siguiente paso corresponde a la definicin de una Lista de Control de Acceso. Especificaremos una denominada passwd la cual se configurar para utilizar obligatoriamente la autenticacin para poder acceder a Squid. Debe localizarse la seccin de Listas de Control de Acceso y aadirse la siguiente lnea: acl password proxy_auth REQUIRED Habiendo hecho lo anterior, deberemos tener en la seccin de Listas de Control de Acceso algo como lo siguiente: Listas de Control de Accesos: autenticacin. # # Recommended minimum configuration: 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 redlocal src 192.168.1.0/255.255.255.0 acl password proxy_auth REQUIRED

Procedemos entonces a modificar la regla de control de accesos que ya tenamos para permitir el acceso a Internet. Donde antes tenamos lo siguiente: http_access allow redlocal Le aadimos passwd, la definicin de la Lista de Control de Acceso que requiere utilizar contrasea, a nuestra regla actual, de modo que quede como mostramos a continuacin: http_access allow redlocal password Habiendo hecho lo anterior, la zona de reglas de control de acceso debera quedar ms o menos de este modo: Reglas de control de acceso: Acceso por contrasea. # # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS # http_access allow localhost http_access allow redlocal password http_access deny all Solo bastar reiniciar Squid para que tomen efecto los cambios y podamos hacer pruebas. /etc/rc.d/init.d/squid restart

Você também pode gostar