control de l'accés web a través de l'squid
(Abans se situa un fitxer "firewall.sh" amb un conjunt d'iptables, entre elles:
# Redireccionem a Squid (port 3128) tot allò destinat al port 80 (http)
iptables -t nat -A PREROUTING -p tcp --dport 80 -i eth0 -s 192.168.1.0/24 -j REDIRECT --to-port=3128
iptables -A INPUT -p tcp --dport 3128 -s 192.168.1.0/24 -j ACCEPT
)
L'objectiu és definir diversos espais al centre que permetin accessos diversos a internet. Bàsicament, aules amb només accés als llocs web decidits pel centre (el fitxer whitelist) i/o que fan referència a conceptes de l'àmbit de l'ensenyament (el fitxer paraulesSi), aules amb accés prohibit a alguns llocs (el fitxer blacklist) i/o que fan referència a contiguts inapropiats per un centre d'ensenyament (el fitxer paraulesNo).
Tots aquests fitxers són fitxers de text que es situen a "/etc/squid/".
Petits exemples de cadascun:
fitxer whitelist (accés a tots els llocs .cat, .edu, etcètera, i només a ells)
.cat
.eu
.edu
.org
.net
.skype.com
.google.com
.google.es
.update.microsoft.com
fitxer blacklist (no permet l'accés a:)
.facebook.com
.facebook.es
.facebook.cat
.redtube.com
.marca.com
.marca.es
.elmundodeportivo.com
.airsoft.es
.tuenti.com
.cuantocabron.com
.interviu.es
.sport.es
.minijuegos.com
.y3.com
.juegosjuegos.com
fitxer paraulesSi (accés a tots els llocs relatius a:)
educació
ensenyament
matemàtiques
filosofia
fitxer paraulesNo (No permet l'accés a llocs relatius a:)
lolitas
porn
porno
pussy
xxx
ass
zzz
fuck
hottest
lesbian
teen
tits
cock
hottie
gay
zorras
shemale
Finalment el fitxer que regula tot això: "squid.conf" (que es troba també a "/etc/squid/":
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
# tot el centre
acl localnet src 192.168.1.0/24
# definim espais
acl departaments src 192.168.1.5-192.168.1.20
acl aula60 src 192.168.1.21-192.168.1.40
acl aula62 src 192.168.1.41-192.168.1.60
acl aula64 src 192.168.1.61-192.168.1.80
acl servidor src 192.168.1.207/32
acl altres1 src 192.168.1.81-192.168.1.165
acl aulesGen src 192.168.1.166-192.168.1.185
acl altres2 src 192.168.1.186-192.168.1.254
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
# definim regles
acl whitelist dstdomain "/etc/squid/whitelist"
acl blacklist dstdomain "/etc/squid/blacklist"
acl paraulesNo url_regex "/etc/squid/paraulesNo"
acl paraulesSi url_regex "/etc/squid/paraulesSi"
# definim l'accés pels diversos espais
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
# accés per defecte: només als llocs whitelist
http_access allow localnet whitelist
# departaments accés sense restriccions
http_access allow departaments
# aules, amb diferents possiblitats d'accés
http_access allow aula60 !blacklist !paraulesNo
http_access allow aula62 !paraulesNo
http_access allow aula64 whitelist
http_access allow aulesGen !paraulesNo
http_access allow servidor
http_access allow localhost
http_access deny all
icp_access allow localnet
icp_access deny all
htcp_access allow localnet
htcp_access deny all
# IP on es troba l'squid
# Tots els ordinadors en què la porta d'enllaç sigui 192.168.1.2 seran filtrats per l'squid
http_port 192.168.1.2:3128 transparent
hierarchy_stoplist cgi-bin ?
# la part del cache
cache_dir aufs /var/cache/squid 40960 16 256
cache_mem 64 MB
maximum_object_size_in_memory 1024 KB
maximum_object_size 81920 KB
access_log /var/log/squid/access.log squid
#imatges
refresh_pattern -i \.jpe?g$ 1440 80% 4320
refresh_pattern -i \.gif$ 1440 80% 4320
# Videu mínim 10 dies, màxim 30
refresh_pattern -i \.mov$ 14400 80% 43200
refresh_pattern -i \.mpe?g?$ 14400 80% 43200
refresh_pattern -i \.avi$ 14400 80% 43200
refresh_pattern -i \.qtm?$ 14400 80% 43200
refresh_pattern -i \.viv$ 14400 80% 43200
refresh_pattern -i \.swf$ 14400 80% 43200
refresh_pattern -i \.flv$ 14400 80% 43200
# So idem que videu
refresh_pattern -i \.wav$ 14400 80% 43200
refresh_pattern -i \.aiff?$ 14400 80% 43200
refresh_pattern -i \.au$ 14400 80% 43200
refresh_pattern -i \.ram?$ 14400 80% 43200
refresh_pattern -i \.snd$ 14400 80% 43200
refresh_pattern -i \.mid$ 14400 80% 43200
refresh_pattern -i \.mp2$ 14400 80% 43200
refresh_pattern -i \.mp3$ 14400 80% 43200
refresh_pattern -i \.ogg$ 14400 80% 43200
#diversos, geogebra
refresh_pattern -i \.ggb$ 14400 80% 43200
# per defecte
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern (cgi-bin|\?) 0 0% 0
refresh_pattern . 0 20% 4320
icp_port 3130
coredump_dir /var/cache/squid
Això em funciona, de moment. Qualsevol comentari i suggeriment per afinar més la cosa o obrir noves possibilitats serà benvingut.
Salut
Joan
editat per: jjuhe2, 19/Gener/2011 - 17:51