Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
310lansecure:30_radius:10_freeradius1 [le 29/03/2009 à 09:39] – prof | 310lansecure:30_radius:10_freeradius1 [le 30/06/2018 à 15:55] (Version actuelle) – prof | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== FreeRADIUS | ||
+ | (2.0.4 sur Debian Lenny). | ||
+ | ===== Avant de commencer... ===== | ||
+ | |||
+ | RADIUS (Remote Authentication Dial-In User Service) est un vaste programme. Pour essayer de faire simple (donc schématique et incomplet), ce service est capable : | ||
+ | |||
+ | * d' | ||
+ | * d' | ||
+ | * de renvoyer au demandeur des paramètres variés pouvant, suivant le cas, être une configuration IP, un numéro de LAN virtuel etc. | ||
+ | |||
+ | Étudier dans le détail toutes les possibilités de RADIUS est hors de la portée de cet exposé. (c' | ||
+ | |||
+ | * authentification depuis leur adresse MAC des stations « connues » sur notre réseau filaire, en utilisant un système de type « login/ | ||
+ | * authentification avec un certificat x.509 sur le réseau Wi-Fi, en utilisant EAP-TLS. | ||
+ | |||
+ | Installer et surtout configurer un serveur radius pour la première fois a quelque chose d' | ||
+ | |||
+ | FreeRadius peut fonctionner en s' | ||
+ | ===== Installation de Freeradius ===== | ||
+ | Pour des raisons de compatibilité de licences, FreeRadius est compilé par défaut sur Debian (Lenny) sans le support de TLS. TLS nous servira pour le WPA2. Nous allons donc reconstruire un paquet binaire à partir du paquet source, en tenant compte de cet usage. | ||
+ | |||
+ | **Notons que ceci n'a plus lieu d' | ||
+ | |||
+ | ==== Préparatifs ==== | ||
+ | |||
+ | Nous aurons besoin de quelques outils de compilation et de gestion des paquets source : | ||
+ | |||
+ | # aptitude install build-essential | ||
+ | ... | ||
+ | # aptitude install apt-src | ||
+ | |||
+ | Puis nous devons mettre à jour la liste des paquets source : | ||
+ | |||
+ | # apt-src update | ||
+ | |||
+ | Enfin, nous installons le paquet source de FreeRadius dans un répertoire que nous aurons créé dans ce but. La commande apt-src install offre, entre autres, l' | ||
+ | |||
+ | # mkdir ~/ | ||
+ | # cd ~/ | ||
+ | # apt-src install freeradius | ||
+ | |||
+ | Nous devons retrouver dans notre répertoire : | ||
+ | < | ||
+ | # ls -l | ||
+ | total 2908 | ||
+ | drwxr-xr-x 15 root root 4096 mar 4 15:14 freeradius-2.0.4+dfsg | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | -rw-r--r-- | ||
+ | </ | ||
+ | |||
+ | ==== Configuration de la compilation ==== | ||
+ | Dans le répertoire '' | ||
+ | |||
+ | Voici la première partie qui nous intéresse : | ||
+ | < | ||
+ | ./ | ||
+ | --prefix=/ | ||
+ | --exec-prefix=/ | ||
+ | --mandir=$(mandir) \ | ||
+ | --sysconfdir=/ | ||
+ | --libdir=$(libdir) \ | ||
+ | --datadir=/ | ||
+ | --localstatedir=/ | ||
+ | --with-raddbdir=$(raddbdir) \ | ||
+ | --with-logdir=/ | ||
+ | --enable-ltdl-install=no --enable-strict-dependencies \ | ||
+ | --with-large-files --with-udpfromto --with-edir \ | ||
+ | --enable-developer \ | ||
+ | --config-cache \ | ||
+ | <span class=" | ||
+ | --without-rlm_eap_ttls \ | ||
+ | --without-rlm_eap_peap \</ | ||
+ | --without-rlm_eap_tnc \ | ||
+ | --without-rlm_otp \ | ||
+ | --with-rlm_sql_postgresql_lib_dir=`pg_config --libdir` \ | ||
+ | --with-rlm_sql_postgresql_include_dir=`pg_config --includedir` \ | ||
+ | <span class=" | ||
+ | --without-rlm_eap_ikev2 \ | ||
+ | --without-rlm_sql_oracle \ | ||
+ | --without-rlm_sql_unixodbc \ | ||
+ | --with-system-libtool | ||
+ | </ | ||
+ | Les lignes surlignées sont celles qu'il faut supprimer pour obtenir le support de TLS. Nous devons donc aboutir à ceci : | ||
+ | < | ||
+ | ./ | ||
+ | --prefix=/ | ||
+ | --exec-prefix=/ | ||
+ | --mandir=$(mandir) \ | ||
+ | --sysconfdir=/ | ||
+ | --libdir=$(libdir) \ | ||
+ | --datadir=/ | ||
+ | --localstatedir=/ | ||
+ | --with-raddbdir=$(raddbdir) \ | ||
+ | --with-logdir=/ | ||
+ | --enable-ltdl-install=no --enable-strict-dependencies \ | ||
+ | --with-large-files --with-udpfromto --with-edir \ | ||
+ | --enable-developer \ | ||
+ | --config-cache \ | ||
+ | --without-rlm_eap_tnc \ | ||
+ | --with-rlm_sql_postgresql_lib_dir=`pg_config --libdir` \ | ||
+ | --with-rlm_sql_postgresql_include_dir=`pg_config --includedir` \ | ||
+ | --without-rlm_eap_ikev2 \ | ||
+ | --without-rlm_sql_oracle \ | ||
+ | --without-rlm_sql_unixodbc \ | ||
+ | --with-system-libtool | ||
+ | </ | ||
+ | Ce serait tout si le concepteur du paquet n' | ||
+ | < | ||
+ | for pkg in ${pkgs} ; do \ | ||
+ | if dh_shlibdeps -p $$pkg -- -O 2>/ | ||
+ | echo "$$pkg links to openssl" | ||
+ | exit 1 ;\ | ||
+ | fi ;\ | ||
+ | done | ||
+ | </ | ||
+ | |||
+ | Il suffit de commenter la ligne '' | ||
+ | < | ||
+ | for pkg in ${pkgs} ; do \ | ||
+ | if dh_shlibdeps -p $$pkg -- -O 2>/ | ||
+ | echo "$$pkg links to openssl" | ||
+ | # exit 1 ;\ | ||
+ | fi ;\ | ||
+ | done | ||
+ | </ | ||
+ | Du côté de la compilation, | ||
+ | |||
+ | Voici donc le fichier « rules » tel qu'il doit finalement se présenter : | ||
+ | < | ||
+ | # | ||
+ | # -*- makefile -*- | ||
+ | # Sample debian/ | ||
+ | # | ||
+ | # This file was originally written by Joey Hess and Craig Small. | ||
+ | # As a special exception, when this file is copied by dh-make into a | ||
+ | # dh-make output file, you may use that output file without restriction. | ||
+ | # This special exception was added by Craig Small in version 0.37 of dh-make. | ||
+ | # | ||
+ | # Modified to make a template file for a multi-binary package with separated | ||
+ | # build-arch and build-indep targets | ||
+ | |||
+ | # Uncomment this to turn on verbose mode. | ||
+ | export DH_VERBOSE=1 | ||
+ | |||
+ | .NOTPARALLEL: | ||
+ | |||
+ | SHELL | ||
+ | |||
+ | package | ||
+ | freeradius_dir | ||
+ | |||
+ | mandir | ||
+ | libdir | ||
+ | logdir | ||
+ | pkgdocdir | ||
+ | raddbdir | ||
+ | |||
+ | modulelist=krb5 ldap sql_mysql sql_iodbc sql_postgresql | ||
+ | pkgs=$(shell dh_listpackages) | ||
+ | |||
+ | # This has to be exported to make some magic below work. | ||
+ | export DH_OPTIONS | ||
+ | |||
+ | # These are used for cross-compiling and for saving the configure script | ||
+ | # from having to guess our platform (since we know it already) | ||
+ | export DEB_HOST_GNU_TYPE | ||
+ | export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) | ||
+ | |||
+ | ifneq (, | ||
+ | CFLAGS += -O0 | ||
+ | else | ||
+ | CFLAGS += -O2 | ||
+ | endif | ||
+ | |||
+ | ifeq ($(DEB_BUILD_GNU_TYPE), | ||
+ | confflags += --build $(DEB_HOST_GNU_TYPE) | ||
+ | else | ||
+ | confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) | ||
+ | endif | ||
+ | |||
+ | config.status: | ||
+ | dh_testdir | ||
+ | |||
+ | ifeq (config.sub.dist, | ||
+ | rm config.sub | ||
+ | else | ||
+ | mv config.sub config.sub.dist | ||
+ | endif | ||
+ | ifeq (config.guess.dist, | ||
+ | rm config.guess | ||
+ | else | ||
+ | mv config.guess config.guess.dist | ||
+ | endif | ||
+ | ln -s / | ||
+ | ln -s / | ||
+ | |||
+ | |||
+ | ./ | ||
+ | --prefix=/ | ||
+ | --exec-prefix=/ | ||
+ | --mandir=$(mandir) \ | ||
+ | --sysconfdir=/ | ||
+ | --libdir=$(libdir) \ | ||
+ | --datadir=/ | ||
+ | --localstatedir=/ | ||
+ | --with-raddbdir=$(raddbdir) \ | ||
+ | --with-logdir=/ | ||
+ | --enable-ltdl-install=no --enable-strict-dependencies \ | ||
+ | --with-large-files --with-udpfromto --with-edir \ | ||
+ | --enable-developer \ | ||
+ | --config-cache \ | ||
+ | --without-rlm_eap_tnc \ | ||
+ | --with-rlm_sql_postgresql_lib_dir=`pg_config --libdir` \ | ||
+ | --with-rlm_sql_postgresql_include_dir=`pg_config --includedir` \ | ||
+ | --without-rlm_eap_ikev2 \ | ||
+ | --without-rlm_sql_oracle \ | ||
+ | --without-rlm_sql_unixodbc \ | ||
+ | --with-system-libtool | ||
+ | |||
+ | # | ||
+ | build: build-arch build-indep | ||
+ | |||
+ | build-arch: build-arch-stamp | ||
+ | build-arch-stamp: | ||
+ | $(MAKE) | ||
+ | touch $@ | ||
+ | |||
+ | build-indep: | ||
+ | build-indep-stamp: | ||
+ | touch $@ | ||
+ | |||
+ | clean: | ||
+ | dh_testdir | ||
+ | dh_testroot | ||
+ | rm -f build-arch-stamp build-indep-stamp | ||
+ | rm -f config.cache config.log | ||
+ | |||
+ | [ ! -d src/ | ||
+ | [ ! -d src/binary ] || rm -fr src/binary || true | ||
+ | |||
+ | # Add here commands to clean up after the build process. | ||
+ | ifeq (Make.inc, | ||
+ | $(MAKE) distclean | ||
+ | endif | ||
+ | ifeq (config.sub.dist, | ||
+ | rm -f config.sub | ||
+ | mv config.sub.dist config.sub | ||
+ | endif | ||
+ | ifeq (config.guess.dist, | ||
+ | rm -f config.guess | ||
+ | mv config.guess.dist config.guess | ||
+ | endif | ||
+ | dh_clean | ||
+ | |||
+ | install: install-indep install-arch | ||
+ | install-indep: | ||
+ | dh_testdir | ||
+ | dh_testroot | ||
+ | dh_installdirs -i | ||
+ | |||
+ | $(MAKE) -C dialup_admin DIALUP_PREFIX=/ | ||
+ | DIALUP_DOCDIR=/ | ||
+ | DIALUP_CONFDIR=/ | ||
+ | R=$(freeradius_dir) install | ||
+ | |||
+ | mv $(freeradius_dir)/ | ||
+ | | ||
+ | mv $(freeradius_dir)/ | ||
+ | | ||
+ | |||
+ | install -m0644 debian/ | ||
+ | |||
+ | dh_install -i --sourcedir=$(freeradius_dir) | ||
+ | dh_installdocs -p freeradius-dialupadmin dialup_admin/ | ||
+ | |||
+ | install-arch: | ||
+ | dh_testdir | ||
+ | dh_testroot | ||
+ | dh_installdirs -s | ||
+ | test -d $(freeradius_dir)/ | ||
+ | ln -s rlm_sql.so $(freeradius_dir)/ | ||
+ | $(MAKE) install R=$(freeradius_dir) | ||
+ | |||
+ | # rename radius binary to play nicely with others | ||
+ | mv $(freeradius_dir)/ | ||
+ | mv $(freeradius_dir)/ | ||
+ | |||
+ | dh_install --sourcedir=$(freeradius_dir) -p libfreeradius2 | ||
+ | dh_install --sourcedir=$(freeradius_dir) -p libfreeradius-dev | ||
+ | |||
+ | for mod in ${modulelist}; | ||
+ | pkg=$${mod## | ||
+ | dh_install --sourcedir=$(freeradius_dir) -p freeradius-$$pkg ; \ | ||
+ | rm -f $(freeradius_dir)/ | ||
+ | done | ||
+ | |||
+ | dh_install --sourcedir=$(freeradius_dir) -p freeradius-utils | ||
+ | dh_install --sourcedir=$(freeradius_dir) -p freeradius | ||
+ | |||
+ | dh_strip -a --dbg-package=freeradius-dbg | ||
+ | |||
+ | dh_makeshlibs -a -n | ||
+ | for pkg in ${pkgs} ; do \ | ||
+ | if dh_shlibdeps -p $$pkg -- -O 2>/ | ||
+ | echo "$$pkg links to openssl" | ||
+ | # exit 1 ;\ | ||
+ | fi ;\ | ||
+ | done | ||
+ | dh_shlibdeps | ||
+ | |||
+ | binary-common: | ||
+ | dh_testdir | ||
+ | dh_testroot | ||
+ | dh_installchangelogs | ||
+ | dh_installdocs | ||
+ | dh_installexamples | ||
+ | dh_installlogrotate | ||
+ | dh_installpam --name=radiusd | ||
+ | dh_installinit --noscripts | ||
+ | dh_installman | ||
+ | dh_lintian | ||
+ | dh_link | ||
+ | dh_compress -Xexamples | ||
+ | dh_fixperms | ||
+ | dh_installdeb | ||
+ | dh_gencontrol | ||
+ | dh_md5sums | ||
+ | dh_builddeb | ||
+ | |||
+ | # Build architecture independant packages using the common target. | ||
+ | binary-indep: | ||
+ | $(MAKE) -f debian/ | ||
+ | |||
+ | # Build architecture dependant packages using the common target. | ||
+ | binary-arch: | ||
+ | $(MAKE) -f debian/ | ||
+ | |||
+ | binary: binary-arch binary-indep | ||
+ | .PHONY: build clean binary-indep binary-arch binary install install-indep install-arch | ||
+ | </ | ||
+ | |||
+ | ==== Le fichier « control » ==== | ||
+ | Nous devons ici ajouter la dépendance à la librairie '' | ||
+ | < | ||
+ | Source: freeradius | ||
+ | <span class=" | ||
+ | Section: net | ||
+ | Priority: optional | ||
+ | Maintainer: Stephen Gran < | ||
+ | Uploaders: Mark Hymers < | ||
+ | Standards-Version: | ||
+ | ... | ||
+ | </ | ||
+ | Et nous assurer qu' | ||
+ | aptitude install libssl-dev | ||
+ | |||
+ | |||
+ | ==== construction des binaires ==== | ||
+ | Il nous reste à construire les paquets binaires : | ||
+ | cd ~/ | ||
+ | apt-src build freeradius | ||
+ | Une fois la compilation terminée, normalement sans message d' | ||
+ | < | ||
+ | ls -l *.deb | ||
+ | <span class=" | ||
+ | -rw-r--r-- 1 root root 205030 fév 22 16:21 freeradius-common_2.0.4+dfsg-6_all.deb</ | ||
+ | -rw-r--r-- 1 root root 949458 fév 22 16:20 freeradius-dbg_2.0.4+dfsg-6_i386.deb | ||
+ | -rw-r--r-- 1 root root 132748 fév 22 16:21 freeradius-dialupadmin_2.0.4+dfsg-6_all.deb | ||
+ | -rw-r--r-- 1 root root 17184 fév 22 16:20 freeradius-iodbc_2.0.4+dfsg-6_i386.deb | ||
+ | -rw-r--r-- 1 root root 18082 fév 22 16:20 freeradius-krb5_2.0.4+dfsg-6_i386.deb | ||
+ | -rw-r--r-- 1 root root 34426 fév 22 16:20 freeradius-ldap_2.0.4+dfsg-6_i386.deb | ||
+ | <span class=" | ||
+ | -rw-r--r-- 1 root root 35364 fév 22 16:20 freeradius-postgresql_2.0.4+dfsg-6_i386.deb | ||
+ | <span class=" | ||
+ | -rw-r--r-- 1 root root 85212 fév 22 16:20 libfreeradius2_2.0.4+dfsg-6_i386.deb</ | ||
+ | -rw-r--r-- 1 root root 103672 fév 22 16:20 libfreeradius-dev_2.0.4+dfsg-6_i386.deb | ||
+ | </ | ||
+ | |||
+ | ==== Installation des paquets utiles ==== | ||
+ | La commande '' | ||
+ | < | ||
+ | dpkg -i libfreeradius2_2.0.4+dfsg-6_i386.deb freeradius-common_2.0.4+dfsg-6_all.deb freeradius_2.0.4+dfsg-6_i386.deb freeradius-mysql_2.0.4+dfsg-6_i386.deb freeradius-utils_2.0.4+dfsg-6_i386.deb | ||
+ | </ | ||
+ | |||
+ | ==== Se protéger des mises à jour de « aptitude » ==== | ||
+ | Si nous compilons maintenant le paquet binaire, nous obtiendrons des paquets ayant le même nom (version comprise), que les binaires de la distribution, | ||
+ | |||
+ | Une solution consiste à utiliser l' | ||
+ | :~# dpkg --get-selections > packages | ||
+ | De manière à obtenir le fichier '' | ||
+ | < | ||
+ | aptitude search freeradius | grep ^i | ||
+ | i | ||
+ | i | ||
+ | i | ||
+ | i | ||
+ | i | ||
+ | </ | ||
+ | |||
+ | Nous retrouvons dans le fichier '' | ||
+ | |||
+ | < | ||
+ | cat packages | grep radius | ||
+ | freeradius install | ||
+ | freeradius-common install | ||
+ | freeradius-mysql install | ||
+ | freeradius-utils install | ||
+ | libfreeradius2 install | ||
+ | </ | ||
+ | |||
+ | Nous devons éditer ce fichier en remplaçant l' | ||
+ | < | ||
+ | cat packages | grep radius | ||
+ | freeradius hold | ||
+ | freeradius-common hold | ||
+ | freeradius-mysql hold | ||
+ | freeradius-utils hold | ||
+ | libfreeradius2 hold | ||
+ | </ | ||
+ | |||
+ | Il nous reste à entrer ces nouvelles informations dans la base de donnée des paquets installés : | ||
+ | |||
+ | :~# dpkg --set-selections < packages | ||
+ | |||
+ | Si tout s'est bien passé, la vérification suivante doit donner : | ||
+ | |||
+ | < | ||
+ | | ||
+ | ih freeradius | ||
+ | ih freeradius-common | ||
+ | ih freeradius-mysql | ||
+ | ih freeradius-utils | ||
+ | ih libfreeradius2 | ||
+ | </ | ||
+ | |||
+ | Le '' | ||
+ | |||
+ | ===== Configuration ===== | ||
+ | ==== Création de la base MySQL ==== | ||
+ | Nous voulons ici faire quelque chose de « simple ». Il sera toujours temps de compliquer les choses une fois que la solution minimale aura été validée. Notre base MySQL contiendra la liste des « utilisateurs » (chez nous des adresses MAC), la liste des « authenticators » (nos switchs et notre borne WI-FI) et éventuellement une liste d' | ||
+ | |||
+ | FreeRADIUS n'aura donc à manipuler cette base qu'en lecture, il n'aura rien à écrire dedans. Nous allons donc créer une base '' | ||
+ | |||
+ | Nous utilisons ici : | ||
+ | # mysql -V | ||
+ | mysql Ver 14.12 Distrib 5.0.51a, for debian-linux-gnu (i486) using readline 5.2 | ||
+ | |||
+ | Création de la base : | ||
+ | # mysql -u root -p | ||
+ | Enter password: | ||
+ | Welcome to the MySQL monitor. | ||
+ | Your MySQL connection id is 42 | ||
+ | Server version: 5.0.51a-24 (Debian) | ||
+ | | ||
+ | Type ' | ||
+ | | ||
+ | mysql> CREATE DATABASE radius; | ||
+ | Query OK, 1 row affected (0.01 sec) | ||
+ | Création de l' | ||
+ | CREATE USER ' | ||
+ | GRANT SELECT ON radius . * TO ' | ||
+ | Pour la création des tables, FreeRADIUS propose des fichiers SQL qui vont nous aider ici. Ils se trouvent dans ''/ | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | Le second s' | ||
+ | |||
+ | Finalement, pour vérification : | ||
+ | < | ||
+ | # mysql -uroot -pepikoi radius | ||
+ | Reading table information for completion of table and column names | ||
+ | You can turn off this feature to get a quicker startup with -A | ||
+ | |||
+ | Welcome to the MySQL monitor. | ||
+ | Your MySQL connection id is 83 | ||
+ | Server version: 5.0.51a-24-log (Debian) | ||
+ | |||
+ | Type ' | ||
+ | |||
+ | mysql> show tables; | ||
+ | +------------------+ | ||
+ | | Tables_in_radius | | ||
+ | +------------------+ | ||
+ | | nas | | ||
+ | | radacct | ||
+ | | radcheck | ||
+ | | radgroupcheck | ||
+ | | radgroupreply | ||
+ | | radpostauth | ||
+ | | radreply | ||
+ | | radusergroup | ||
+ | +------------------+ | ||
+ | 8 rows in set (0.00 sec) | ||
+ | </ | ||
+ | |||
+ | ==== Configuration de FreeRADIUS ==== | ||
+ | C'est maintenant que nous allons vraiment commencer à nous amuser. En effet il y a pas mal de fichiers qui ont été placés dans ''/ | ||
+ | |||
+ | Dans ''/ | ||
+ | < | ||
+ | # cat radiusd.conf | egrep -v -e ' | ||
+ | $INCLUDE proxy.conf | ||
+ | $INCLUDE clients.conf | ||
+ | $INCLUDE snmp.conf | ||
+ | $INCLUDE eap.conf | ||
+ | $INCLUDE policy.conf | ||
+ | $INCLUDE sites-enabled/ | ||
+ | </ | ||
+ | |||
+ | Dans notre cas très simple : | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | En revanche : | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | Il reste enfin le fichier '' | ||
+ | |||
+ | Au final, nous avons à voir et à modifier : | ||
+ | * ''/ | ||
+ | * ''/ | ||
+ | * ''/ | ||
+ | * ''/ | ||
+ | |||
+ | Et nous supprimerons dans ''/ | ||
+ | |||
+ | Lorsque je vous disais qu'il y a de quoi s' | ||
+ | === radiusd.conf === | ||
+ | Première chose à faire : | ||
+ | cd / | ||
+ | mv radiusd.conf radiusd.conf.dist | ||
+ | |||
+ | Deuxième chose à faire : **Lire le contenu de '' | ||
+ | |||
+ | Troisième chose : | ||
+ | cat radiusd.conf.dist | egrep -v -e ' | ||
+ | De manière à ne pas se bousiller les yeux à chercher les lignes « utiles » dans la forêt de commentaires. | ||
+ | |||
+ | Nous obtenons quelque chose qui ressemble à : | ||
+ | < | ||
+ | prefix = /usr | ||
+ | exec_prefix = /usr | ||
+ | sysconfdir = /etc | ||
+ | localstatedir = /var | ||
+ | sbindir = ${exec_prefix}/ | ||
+ | logdir = / | ||
+ | raddbdir = / | ||
+ | radacctdir = ${logdir}/ | ||
+ | confdir = ${raddbdir} | ||
+ | run_dir = ${localstatedir}/ | ||
+ | db_dir = $(raddbdir) | ||
+ | libdir = / | ||
+ | pidfile = ${run_dir}/ | ||
+ | user = freerad | ||
+ | group = freerad | ||
+ | max_request_time = 30 | ||
+ | cleanup_delay = 5 | ||
+ | max_requests = 1024 | ||
+ | listen { | ||
+ | type = auth | ||
+ | ipaddr = * | ||
+ | port = 0 | ||
+ | } | ||
+ | listen { | ||
+ | ipaddr = * | ||
+ | port = 0 | ||
+ | type = acct | ||
+ | } | ||
+ | hostname_lookups = no | ||
+ | allow_core_dumps = no | ||
+ | regular_expressions = yes | ||
+ | extended_expressions = yes | ||
+ | log { | ||
+ | destination = files | ||
+ | file = ${logdir}/ | ||
+ | syslog_facility = daemon | ||
+ | stripped_names = no | ||
+ | auth = no | ||
+ | auth_badpass = no | ||
+ | auth_goodpass = no | ||
+ | } | ||
+ | checkrad = ${sbindir}/ | ||
+ | security { | ||
+ | max_attributes = 200 | ||
+ | reject_delay = 1 | ||
+ | status_server = yes | ||
+ | } | ||
+ | <span class=" | ||
+ | #$INCLUDE proxy.conf | ||
+ | #$INCLUDE clients.conf</ | ||
+ | snmp = no | ||
+ | <span class=" | ||
+ | thread pool { | ||
+ | start_servers = 5 | ||
+ | max_servers = 32 | ||
+ | min_spare_servers = 3 | ||
+ | max_spare_servers = 10 | ||
+ | max_requests_per_server = 0 | ||
+ | } | ||
+ | modules { | ||
+ | <span class=" | ||
+ | # | ||
+ | # | ||
+ | chap { | ||
+ | authtype = CHAP | ||
+ | } | ||
+ | <span class=" | ||
+ | # pam_auth = radiusd | ||
+ | # } | ||
+ | # unix { | ||
+ | # radwtmp = ${logdir}/ | ||
+ | # | ||
+ | $INCLUDE eap.conf | ||
+ | mschap { | ||
+ | } | ||
+ | ldap { | ||
+ | server = " | ||
+ | basedn = "o=My Org, | ||
+ | filter = " | ||
+ | ldap_connections_number = 5 | ||
+ | timeout = 4 | ||
+ | timelimit = 3 | ||
+ | net_timeout = 1 | ||
+ | tls { | ||
+ | start_tls = no | ||
+ | } | ||
+ | dictionary_mapping = ${confdir}/ | ||
+ | edir_account_policy_check = no | ||
+ | } | ||
+ | realm IPASS { | ||
+ | format = prefix | ||
+ | delimiter = "/" | ||
+ | } | ||
+ | realm suffix { | ||
+ | format = suffix | ||
+ | delimiter = " | ||
+ | } | ||
+ | realm realmpercent { | ||
+ | format = suffix | ||
+ | delimiter = " | ||
+ | } | ||
+ | realm ntdomain { | ||
+ | format = prefix | ||
+ | delimiter = " | ||
+ | } | ||
+ | checkval { | ||
+ | item-name = Calling-Station-Id | ||
+ | check-name = Calling-Station-Id | ||
+ | data-type = string | ||
+ | } | ||
+ | |||
+ | preprocess { | ||
+ | huntgroups = ${confdir}/ | ||
+ | hints = ${confdir}/ | ||
+ | with_ascend_hack = no | ||
+ | ascend_channels_per_line = 23 | ||
+ | with_ntdomain_hack = no | ||
+ | with_specialix_jetstream_hack = no | ||
+ | with_cisco_vsa_hack = no | ||
+ | } | ||
+ | files { | ||
+ | usersfile = ${confdir}/ | ||
+ | acctusersfile = ${confdir}/ | ||
+ | preproxy_usersfile = ${confdir}/ | ||
+ | compat = no | ||
+ | } | ||
+ | detail { | ||
+ | detailfile = ${radacctdir}/ | ||
+ | detailperm = 0600 | ||
+ | header = " | ||
+ | } | ||
+ | acct_unique { | ||
+ | key = " | ||
+ | } | ||
+ | <span class=" | ||
+ | radutmp { | ||
+ | filename = ${logdir}/ | ||
+ | username = %{User-Name} | ||
+ | case_sensitive = yes | ||
+ | check_with_nas = yes | ||
+ | perm = 0600 | ||
+ | callerid = " | ||
+ | } | ||
+ | radutmp sradutmp { | ||
+ | filename = ${logdir}/ | ||
+ | perm = 0644 | ||
+ | callerid = " | ||
+ | } | ||
+ | attr_filter attr_filter.post-proxy { | ||
+ | attrsfile = ${confdir}/ | ||
+ | } | ||
+ | attr_filter attr_filter.pre-proxy { | ||
+ | attrsfile = ${confdir}/ | ||
+ | } | ||
+ | attr_filter attr_filter.access_reject { | ||
+ | key = %{User-Name} | ||
+ | attrsfile = ${confdir}/ | ||
+ | } | ||
+ | attr_filter attr_filter.accounting_response { | ||
+ | key = %{User-Name} | ||
+ | attrsfile = ${confdir}/ | ||
+ | } | ||
+ | counter daily { | ||
+ | filename = ${db_dir}/ | ||
+ | key = User-Name | ||
+ | count-attribute = Acct-Session-Time | ||
+ | reset = daily | ||
+ | counter-name = Daily-Session-Time | ||
+ | check-name = Max-Daily-Session | ||
+ | reply-name = Session-Timeout | ||
+ | allowed-servicetype = Framed-User | ||
+ | cache-size = 5000 | ||
+ | } | ||
+ | always fail { | ||
+ | rcode = fail | ||
+ | } | ||
+ | always reject { | ||
+ | rcode = reject | ||
+ | } | ||
+ | always noop { | ||
+ | rcode = noop | ||
+ | } | ||
+ | always handled { | ||
+ | rcode = handled | ||
+ | } | ||
+ | always updated { | ||
+ | rcode = updated | ||
+ | } | ||
+ | always notfound { | ||
+ | rcode = notfound | ||
+ | } | ||
+ | always ok { | ||
+ | rcode = ok | ||
+ | simulcount = 0 | ||
+ | mpp = no | ||
+ | } | ||
+ | expr { | ||
+ | } | ||
+ | digest { | ||
+ | } | ||
+ | expiration { | ||
+ | reply-message = " | ||
+ | } | ||
+ | logintime { | ||
+ | reply-message = "You are calling outside your allowed timespan\r\n" | ||
+ | minimum-timeout = 60 | ||
+ | } | ||
+ | exec { | ||
+ | wait = yes | ||
+ | input_pairs = request | ||
+ | shell_escape = yes | ||
+ | output = none | ||
+ | } | ||
+ | exec echo { | ||
+ | wait = yes | ||
+ | program = "/ | ||
+ | input_pairs = request | ||
+ | output_pairs = reply | ||
+ | shell_escape = yes | ||
+ | } | ||
+ | ippool main_pool { | ||
+ | range-start = 192.168.1.1 | ||
+ | range-stop = 192.168.3.254 | ||
+ | netmask = 255.255.255.0 | ||
+ | cache-size = 800 | ||
+ | session-db = ${db_dir}/ | ||
+ | ip-index = ${db_dir}/ | ||
+ | override = no | ||
+ | maximum-timeout = 0 | ||
+ | } | ||
+ | policy { | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | instantiate { | ||
+ | exec | ||
+ | expr | ||
+ | expiration | ||
+ | logintime | ||
+ | } | ||
+ | $INCLUDE policy.conf | ||
+ | $INCLUDE sites-enabled/ | ||
+ | </ | ||
+ | Il y a dans ce fichier plein de choses que nous pourrions enlever car elles ne nous servent à rien (dans notre cas...). Les lignes surlignées montrent ce qu'il est nécessaire de modifier pour nos besoins. | ||
+ | |||
+ | === sites-avalable/ | ||
+ | Assez peu de choses dans ce fichier, compte tenu de la simplicité de nos besoins : | ||
+ | < | ||
+ | authorize { | ||
+ | preprocess | ||
+ | eap { | ||
+ | ok = return | ||
+ | } | ||
+ | sql | ||
+ | } | ||
+ | authenticate { | ||
+ | Auth-Type CHAP { | ||
+ | chap | ||
+ | } | ||
+ | eap | ||
+ | } | ||
+ | session { | ||
+ | sql | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === eap.conf === | ||
+ | Il s'agit d' | ||
+ | |||
+ | Nous avons décidé, en préparant notre système Wi-Fi, d' | ||
+ | |||
+ | * root_maison_CA-cacert.pem qui est le certificat de notre racine de confiance, | ||
+ | * sysop@maison.mrs-cert.pem qui est le certificat du serveur FreeRADIUS. Nous l' | ||
+ | |||
+ | Nous allons utiliser ici ces deux certificats, | ||
+ | |||
+ | De même, nous pouvons y créer le fichier '' | ||
+ | openssl dhparam -check -text -5 512 -out dh | ||
+ | Ainsi qu'un fichier '' | ||
+ | dd if=/ | ||
+ | |||
+ | Ce répertoire devrait finalement contenir : | ||
+ | < | ||
+ | / | ||
+ | total 12 | ||
+ | -rw-r----- 1 root freerad | ||
+ | -rw-r----- 1 root freerad 3242 2007-03-12 15:38 maison.mrs-cert.pem | ||
+ | -rw-r----- 1 root freerad 1024 2007-03-12 11:11 random | ||
+ | -rw-r----- 1 root freerad 2610 2007-03-12 15:25 root_maison_CA-cacert.pem | ||
+ | </ | ||
+ | Faites attention aux droits d' | ||
+ | < | ||
+ | eap { | ||
+ | default_eap_type = tls | ||
+ | timer_expire | ||
+ | ignore_unknown_eap_types = no | ||
+ | cisco_accounting_username_bug = no | ||
+ | tls { | ||
+ | private_key_password = epikoi | ||
+ | private_key_file = ${raddbdir}/ | ||
+ | certificate_file = ${raddbdir}/ | ||
+ | CA_file = ${raddbdir}/ | ||
+ | CA_path = ${raddbdir}/ | ||
+ | dh_file = ${raddbdir}/ | ||
+ | random_file = ${raddbdir}/ | ||
+ | fragment_size = 1024 | ||
+ | include_length = yes | ||
+ | check_crl = no | ||
+ | } | ||
+ | |||
+ | mschapv2 { | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === sql.conf === | ||
+ | Nous avons une base MySQL '' | ||
+ | < | ||
+ | sql { | ||
+ | database = " | ||
+ | driver = " | ||
+ | server = " | ||
+ | login = " | ||
+ | password = " | ||
+ | radius_db = " | ||
+ | acct_table1 = " | ||
+ | acct_table2 = " | ||
+ | postauth_table = " | ||
+ | authcheck_table = " | ||
+ | authreply_table = " | ||
+ | groupcheck_table = " | ||
+ | groupreply_table = " | ||
+ | usergroup_table = " | ||
+ | deletestalesessions = yes | ||
+ | sqltrace = no | ||
+ | sqltracefile = ${logdir}/ | ||
+ | num_sql_socks = 5 | ||
+ | connect_failure_retry_delay = 60 | ||
+ | nas_table = " | ||
+ | $INCLUDE sql/ | ||
+ | readclients = yes | ||
+ | } | ||
+ | </ | ||
+ | Le fichier inclus '' | ||
+ | |||
+ | ===== Vérifions... ===== | ||
+ | |||
+ | ==== Essai chap ==== | ||
+ | Nous créons un « authenticator » de test dans la table « nas » : | ||
+ | |||
+ | echo " | ||
+ | |||
+ | Nous créons un utilisateur de test dans « radcheck » : | ||
+ | |||
+ | echo " | ||
+ | |||
+ | Enfin nous démarrons freeradius en mode « debug », dans une console avec : | ||
+ | freeradius -X | ||
+ | |||
+ | Le mode « debug » s' | ||
+ | |||
+ | < | ||
+ | FreeRADIUS Version 2.0.4, for host i486-pc-linux-gnu, | ||
+ | Copyright (C) 1999-2008 The FreeRADIUS server project and contributors. | ||
+ | There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A | ||
+ | PARTICULAR PURPOSE. | ||
+ | You may redistribute copies of FreeRADIUS under the terms of the | ||
+ | GNU General Public License. | ||
+ | Starting - reading configuration files ... | ||
+ | <span class=" | ||
+ | including configuration file / | ||
+ | including configuration file / | ||
+ | including configuration file / | ||
+ | including configuration file / | ||
+ | including files in directory / | ||
+ | including configuration file / | ||
+ | including dictionary file / | ||
+ | main { | ||
+ | prefix = "/ | ||
+ | localstatedir = "/ | ||
+ | logdir = "/ | ||
+ | libdir = "/ | ||
+ | radacctdir = "/ | ||
+ | hostname_lookups = no | ||
+ | max_request_time = 30 | ||
+ | cleanup_delay = 5 | ||
+ | max_requests = 1024 | ||
+ | allow_core_dumps = no | ||
+ | pidfile = "/ | ||
+ | user = " | ||
+ | group = " | ||
+ | checkrad = "/ | ||
+ | debug_level = 0 | ||
+ | proxy_requests = yes | ||
+ | | ||
+ | max_attributes = 200 | ||
+ | reject_delay = 1 | ||
+ | status_server = yes | ||
+ | } | ||
+ | } | ||
+ | radiusd: #### Loading Realms and Home Servers #### | ||
+ | radiusd: #### Instantiating modules #### | ||
+ | | ||
+ | | ||
+ | | ||
+ | exec { | ||
+ | wait = yes | ||
+ | input_pairs = " | ||
+ | shell_escape = yes | ||
+ | } | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | expiration { | ||
+ | reply-message = " | ||
+ | } | ||
+ | | ||
+ | | ||
+ | logintime { | ||
+ | reply-message = "You are calling outside your allowed timespan | ||
+ | minimum-timeout = 60 | ||
+ | } | ||
+ | } | ||
+ | radiusd: #### Loading Virtual Servers #### | ||
+ | server { | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | eap { | ||
+ | default_eap_type = " | ||
+ | timer_expire = 60 | ||
+ | ignore_unknown_eap_types = no | ||
+ | cisco_accounting_username_bug = no | ||
+ | } | ||
+ | | ||
+ | | ||
+ | tls { | ||
+ | rsa_key_exchange = no | ||
+ | dh_key_exchange = yes | ||
+ | rsa_key_length = 512 | ||
+ | dh_key_length = 512 | ||
+ | verify_depth = 0 | ||
+ | CA_path = "/ | ||
+ | pem_file_type = yes | ||
+ | private_key_file = "/ | ||
+ | certificate_file = "/ | ||
+ | CA_file = "/ | ||
+ | private_key_password = " | ||
+ | dh_file = "/ | ||
+ | random_file = "/ | ||
+ | fragment_size = 1024 | ||
+ | include_length = yes | ||
+ | check_crl = no | ||
+ | } | ||
+ | | ||
+ | | ||
+ | | ||
+ | with_ntdomain_hack = no | ||
+ | } | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | preprocess { | ||
+ | huntgroups = "/ | ||
+ | hints = "/ | ||
+ | with_ascend_hack = no | ||
+ | ascend_channels_per_line = 23 | ||
+ | with_ntdomain_hack = no | ||
+ | with_specialix_jetstream_hack = no | ||
+ | with_cisco_vsa_hack = no | ||
+ | with_alvarion_vsa_hack = no | ||
+ | } | ||
+ | | ||
+ | | ||
+ | sql { | ||
+ | driver = " | ||
+ | server = " | ||
+ | port = "" | ||
+ | login = " | ||
+ | password = " | ||
+ | radius_db = " | ||
+ | read_groups = yes | ||
+ | sqltrace = yes | ||
+ | sqltracefile = "/ | ||
+ | readclients = yes | ||
+ | deletestalesessions = yes | ||
+ | num_sql_socks = 5 | ||
+ | sql_user_name = " | ||
+ | default_user_profile = "" | ||
+ | nas_query = " | ||
+ | authorize_check_query = " | ||
+ | authorize_reply_query = " | ||
+ | authorize_group_check_query = " | ||
+ | authorize_group_reply_query = " | ||
+ | accounting_onoff_query = "" | ||
+ | accounting_update_query = "" | ||
+ | accounting_update_query_alt = "" | ||
+ | accounting_start_query = "" | ||
+ | accounting_start_query_alt = "" | ||
+ | accounting_stop_query = "" | ||
+ | accounting_stop_query_alt = "" | ||
+ | group_membership_query = " | ||
+ | connect_failure_retry_delay = 60 | ||
+ | simul_count_query = "" | ||
+ | simul_verify_query = "" | ||
+ | postauth_query = " | ||
+ | safe-characters = " | ||
+ | } | ||
+ | rlm_sql (sql): Driver rlm_sql_mysql (module rlm_sql_mysql) loaded and linked | ||
+ | rlm_sql (sql): Attempting to connect to radius@localhost:/ | ||
+ | rlm_sql (sql): starting 0 | ||
+ | rlm_sql (sql): Attempting to connect rlm_sql_mysql #0 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Connected new DB handle, #0 | ||
+ | rlm_sql (sql): starting 1 | ||
+ | rlm_sql (sql): Attempting to connect rlm_sql_mysql #1 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Connected new DB handle, #1 | ||
+ | rlm_sql (sql): starting 2 | ||
+ | rlm_sql (sql): Attempting to connect rlm_sql_mysql #2 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Connected new DB handle, #2 | ||
+ | rlm_sql (sql): starting 3 | ||
+ | rlm_sql (sql): Attempting to connect rlm_sql_mysql #3 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Connected new DB handle, #3 | ||
+ | rlm_sql (sql): starting 4 | ||
+ | rlm_sql (sql): Attempting to connect rlm_sql_mysql #4 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Connected new DB handle, #4 | ||
+ | rlm_sql (sql): Processing generate_sql_clients | ||
+ | rlm_sql (sql) in generate_sql_clients: | ||
+ | rlm_sql (sql): Reserving sql socket id: 4 | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Read entry nasname=127.0.0.1, | ||
+ | rlm_sql (sql): Adding client 127.0.0.1 (localhost, server=< | ||
+ | rlm_sql (sql): Released sql socket id: 4 | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | radiusd: #### Opening IP addresses and Ports #### | ||
+ | listen { | ||
+ | type = " | ||
+ | ipaddr = * | ||
+ | port = 0 | ||
+ | } | ||
+ | listen { | ||
+ | type = " | ||
+ | ipaddr = * | ||
+ | port = 0 | ||
+ | } | ||
+ | main { | ||
+ | snmp = no | ||
+ | smux_password = "" | ||
+ | snmp_write_access = no | ||
+ | } | ||
+ | <span class=" | ||
+ | Listening on accounting address * port 1813 | ||
+ | Listening on proxy address * port 1814 | ||
+ | Ready to process requests.</ | ||
+ | </ | ||
+ | |||
+ | Notez la liste de tous les fichiers inclus, en cas de problème. Notez également que le serveur, si rien n'a coincé dans la configuration, | ||
+ | |||
+ | Dans une autre console, nous allons essayer une authentification avec l' | ||
+ | radtest test0 userpassword 127.0.0.1 0 naspassword | ||
+ | |||
+ | Nous devrions obtenir la réponse : | ||
+ | < | ||
+ | Sending Access-Request of id 197 to 127.0.0.1 port 1812 | ||
+ | User-Name = " | ||
+ | User-Password = " | ||
+ | NAS-IP-Address = 127.0.1.1 | ||
+ | NAS-Port = 0 | ||
+ | <span class=" | ||
+ | </ | ||
+ | |||
+ | Dans la console où s' | ||
+ | |||
+ | < | ||
+ | <span class=" | ||
+ | User-Name = " | ||
+ | User-Password = " | ||
+ | NAS-IP-Address = 127.0.1.1 | ||
+ | NAS-Port = 0 | ||
+ | +- entering group authorize | ||
+ | ++[preprocess] returns ok | ||
+ | rlm_eap: No EAP-Message, | ||
+ | ++[eap] returns noop | ||
+ | expand: %{User-Name} -> test0 | ||
+ | rlm_sql (sql): sql_set_user escaped user --> ' | ||
+ | rlm_sql (sql): Reserving sql socket id: 3 | ||
+ | expand: SELECT id, username, attribute, value, op FROM radcheck WHERE username = ' | ||
+ | <span class=" | ||
+ | rlm_sql (sql): User found in radcheck table</ | ||
+ | expand: SELECT id, username, attribute, value, op FROM radreply WHERE username = ' | ||
+ | rlm_sql_mysql: | ||
+ | expand: SELECT groupname FROM radusergroup WHERE username = ' | ||
+ | rlm_sql_mysql: | ||
+ | rlm_sql (sql): Released sql socket id: 3 | ||
+ | ++[sql] returns ok | ||
+ | <span class=" | ||
+ | auth: user supplied User-Password matches local User-Password | ||
+ | Login OK: [test0/ | ||
+ | Sending Access-Accept of id 197 to 127.0.0.1 port 50494</ | ||
+ | Finished request 0. | ||
+ | Going to the next request | ||
+ | Waking up in 4.9 seconds. | ||
+ | Cleaning up request 0 ID 197 with timestamp +6 | ||
+ | Ready to process requests. | ||
+ | </ | ||
+ | |||
+ | Notre authentification par nom d' |
FreeRADIUS: Dernière modification le: 01/01/1970 à 00:00 par