L’objectif est de monter une machine passerelle FreeBSD qui agit comme un serveur de contenu – filtrage avec Squid DansGuardian. Squid et DansGuardian sont d’excellents outils pour la mise en cache et de filtrage de contenu. Cette configuration a été testée et confirmée avec succès sur un FreeBSD 8.2 Système.
Exigences
- un accès root ou sudo droits
- Basic comprendre de l’ OpenBSD Packet Filter
- Votre appareil est configuré et fonctionne comme passerelle – pare-feu de votre réseau. Jeter un oeil à Gateways and Routes chapter of the FreeBSD Handbook pour plus d’informations.
Si vous exécutez pfSense , vous pouvez installer Squid et DansGuardian trop.Egalement il y a un tutoriel intéressant qui est de celui sur la création de plugins pour FreeBSD new pkgng et la gestion des paquets écriture des plugins pour pkgng.
Commençons!
Une question se pose:
comment installer et configurer Squid comme serveur proxy transparent et DansGuardian pour le filtrage de contenu sur un système FreeBSD?
La première chose est d’utiliser FreeBSD Ports Collection. Et nous retiendrons les options telles que:
- SQUID_LDAP_AUTH
- SQUID_DELAY_POOLS
- SQUID_CARP
- SQUID_WCCP
- SQUID_IDENT
- SQUID_ARP_ACL
- SQUID_PF
- SQUID_FOLLOW_XFF
- SQUID_KQUEUE
- SQUID_SSL
- SQUID_REFERER_LOG
- SQUID_USERAGENT_LOG
- SQUID_ARP_ACL
- SQUID_LARGEFILE
Mais c’est quoi squid?
Depuis le site officiel de squid
On peut lire que squid est un proxy de cache pour le Web supportant HTTP, HTTPS, FTP, et plus encore. Il réduit la bande passante et améliore les temps de réponse en mettant en cache et la réutilisation des pages Web fréquemment demandés. Squid dispose de contrôles d’accès étendus et rend un accélérateur grand serveur. Il fonctionne sur les systèmes d’exploitation les plus disponibles, y compris Windows et est sous licence GNU GPL.
Quand tout est instal, on configure ainsi:
Squid’s main configuration file resides in /usr/local/etc/squid/squid.conf.
Fichier de configuration de Squid principale dans:
/usr/local/etc/squid/squid.conf
ET donc on ouvre et on peut y faire de l’édition et faire les changements nécessaires. La plupart des options sont explicites.
Consultez le Squid man:
/usr/local/etc/squid/squid.conf.default
En grosso-modo c’est assez bien documenté.
Mais les choses les plus importantes que vous avez besoin de changer pour votre configuration sont:
- http_port <firewall-ip-address>:3128 transparent - change avec l’adresse IP de votre firewall.
- visible_hostname <firewall-fqdn> - changement de nom de domaine complet de votre firewall.
- cache_mgr admin@gnagnagna.org – mettre l’adresse e-mail de votre administrateur ici
- intranet_subnet and openvpn_subnet sont deux sous-réseaux qui nous permettent d’accéder à notre serveur proxy.
- SVP consultez le fichier de configuration squid.conf.default pour plus d’explications sur les options utilisées ci-dessus.
Réglage final de FreeBSD.
Pour affiner FreeBSD afin d’être en mesure d’ouvrir plus de fichiers et de processus, ajoutez à votre fichier /boot/loader.conf file.
kern.maxfiles="12328"kern.maxfilesperproc="11095"kern.maxproc="6164"kern.maxprocperuid="5547"kern.maxusers="256"# Enable Squidsquid_enable="YES"|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
ext_if = "<external-interface>"int_if = "<internal-interface>" # --- IP given by the ISP ---ip_addr = "x.x.x.x" # --- squid server ip address (usually the localhost) ---SQUID_SERVER = "x.x.x.x" # --- squid port ---SQUID_PORT = "3128" # --- hosts with internet access from the private network ---table <allowed> { 10.1.16.0/20 } # --- openvpn clients subnet ---table <openvpn_clients> { 10.1.32.0/20 } # --- OPTIONS section ---set skip on lo0set block-policy return # --- SCRUB section ---scrub in all # --- TRANSLATION (NAT/RDR) section ---nat on $ext_if from to any -> $ip_addrnat on $ext_if from <openvpn_clients> to any -> $ip_addr# --- redirect HTTP traffic to the Squid server on the firewall --- rdr on $int_if inet proto tcp from any to any port www -> $SQUID_SERVER port $SQUID_PORT# --- FILTER RULES --- # --- default policy ---block log all # --- antispoof protection ---antispoof quick for $ext_if inetantispoof quick for $int_if inet # --- INTERNAL interface --- pass in quick on $int_if inet from to any keep statepass in quick on $int_if inet from <openvpn_clients> to any keep statepass out quick on $int_if inet from any to any keep state # --- EXTERNAL interface --- pass out quick on $ext_if inet from any to any keep state |
Recharger les regles pf(4) et utilisez pfctl(8).
|
1
|
# pfctl -f /etc/pf.conf |
# squid -f /usr/local/etc/squid/squid.conf -k parse# squid -zla seconde question se pose:
comment installer et configurer DansGuardian ( un système de filtrage de contenu Web ). ET l’intégrer avec Squid.
Pour installer DansGuardian sur votre système FreeBSD vous devez tout d’abord récupérer l’archive de distribution à partir du site de DansGuardian et le placer dans votre répertoire /usr/ports/distfiles. Une fois que vous faites cela, nous pouvons continuer avec l’installation de DansGuardian en utilisant FreeBSD Ports Collection.
Une fois installé, nous passons à la configuration.
Le fichier de configuration principal DansGuardian se trouve dans / usr / local / etc / dansguardian / dansguardian.conf.
Et nous allons seulement changer quelques options afin de correspondre à notre configuration. Donc, ouvrez le répertoire / usr / local / etc / dansguardian fichier / dansguardian.conf pour l’éditer et faire les changements nécessaires.
|
1
2
3
4
5
6
7
|
filterip = filterport = 8080 # dansguardian portproxyip = proxyport = 3128 # Squid's portaccessdeniedaddress = 'http://>/cgi-bin/dansguardian.pl'forwardedfor = onloglocation = '/var/log/dansguardian/access.log' |
Création du journal DansGuardian et les donner les droits/permissions:
|
1
2
3
4
|
# mkdir /var/log/dansguardian# touch /var/log/dansguardian/access.log# chown -R nobody:nobody /var/log/dansguardian# chmod -R 0600 /var/log/dansguardian |
Et ajouter les lignes suivantes à votre fichier / etc / rc.conf:
# Enable DansGuardiandansguardian_enable="YES"|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
ext_if = "<external-interface>"int_if = "<internal-interface>" # --- IP given by the ISP ---ip_addr = "x.x.x.x" # --- squid server ip address (usually the localhost) ---SQUID_SERVER = "x.x.x.x" # --- squid port ---SQUID_PORT = "3128"# --- dansguardian port ---DG_PORT = "8080" # --- hosts with internet access from the private network ---table <allowed> { 10.1.16.0/20 } # --- openvpn clients subnet ---table <openvpn_clients> { 10.1.32.0/20 } # --- OPTIONS section ---set skip on lo0set block-policy return # --- SCRUB section ---scrub in all # --- TRANSLATION (NAT/RDR) section ---nat on $ext_if from <allowed> to any -> $ip_addrnat on $ext_if from <openvpn_clients> to any -> $ip_addr# --- redirect HTTP traffic to the Squid server on the firewall --- rdr on $int_if inet proto tcp from any to any port www -> $SQUID_SERVER port $DG_PORT# --- FILTER RULES --- # --- default policy ---block log all # --- antispoof protection ---antispoof quick for $ext_if inetantispoof quick for $int_if inet # --- INTERNAL interface --- pass in quick on $int_if inet from <allowed> to any keep statepass in quick on $int_if inet from <openvpn_clients> to any keep statepass out quick on $int_if inet from any to any keep state # --- EXTERNAL interface --- pass out quick on $ext_if inet from any to any keep state</openvpn_clients></allowed></openvpn_clients></allowed></openvpn_clients></allowed> |
# pfctl -f /etc/pf.conf# /usr/local/etc/rc.d/dansguardian startEt comme tout est ok, on a now une installation entièrement fonctionnelle avec Squid proxy transparent et filtre de contenu DansGuardian.
Amen.
