Añadir schema zarafa a openLdap

Otra entrada que es un apunte.

Recientemente he tenido que volver a instalar otro zarafa y necesitaba añadir el esquema en el openLdap.

Tras intentar importar el schema con zcat:

zcat /usr/share/doc/zarafa/zarafa.ldif.gz | ldapadd -H ldapi:/// -Y EXTERNAL

Y ver los múltiples errores con las comillas, atributos y demás gaitas, googleando he visto este post:


http://www.linuxquestions.org/questions/linux-server-73/how-to-add-a-new-schema-to-openldap-2-4-11-a-700452/

Resumiendo……. para poder importar el schema de manera correcta, los pasos:

1º) Generamos el fichero schema_convert.conf con el siguiente contenido:

include /etc/ldap/schema/core.schema
include /etc/ldap/schema/collective.schema
include /etc/ldap/schema/corba.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/duaconf.schema
include /etc/ldap/schema/dyngroup.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/java.schema
include /etc/ldap/schema/misc.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/openldap.schema
include /etc/ldap/schema/pmi.schema
include /etc/ldap/schema/ppolicy.schema
include /etc/ldap/schema/zarafa.schema

2º) Creamos el directorio temporal

# mkdir /tmp/ldif_output

3º) Generamos los ldif

# slaptest -f schema_convert.conf -F /tmp/ldif_output

4º) Nos vamos al directorio donde hemos generado los ficheros

cd tmp/ldif_output/cn=config/cn=schema

Y creamos el fichero fixit.sed con el siguiente contenido:

s~dn: cn=\{([0-9]+)\}(.*)$~dn: cn=\2,cn=schema,cn=config~g
s~cn: \{([0-9]+)\}(.*)$~cn: \2~g
s~^(structuralObjectClass|entryUUID|creatorsName|createTimestamp|entryCSN|modifiersName|modifyTimestamp):.*$~~g

5º) Una vez creado el fichero, creamos el directorio fixed y ejecutamos el siguiente script:

for f in *ldif; do sed -rf fixit.sed "$f" > fixed/$f; done

Llegados aquí, en el directorio fixed, tendremos los directorios:

root@radius:/tmp/ldif_output/cn=config/cn=schema/fixed# ls -l
total 96
-rw-r--r-- 1 root root 15267 Aug 24 10:39 cn={0}core.ldif
-rw-r--r-- 1 root root 1091 Aug 24 10:39 cn={10}openldap.ldif
-rw-r--r-- 1 root root 6212 Aug 24 10:39 cn={11}pmi.ldif
-rw-r--r-- 1 root root 3073 Aug 24 10:39 cn={12}ppolicy.ldif
-rw-r--r-- 1 root root 11121 Aug 24 10:39 cn={13}zarafa.ldif
-rw-r--r-- 1 root root 1289 Aug 24 10:39 cn={1}collective.ldif
-rw-r--r-- 1 root root 1051 Aug 24 10:39 cn={2}corba.ldif
-rw-r--r-- 1 root root 11129 Aug 24 10:39 cn={3}cosine.ldif
-rw-r--r-- 1 root root 4253 Aug 24 10:39 cn={4}duaconf.ldif
-rw-r--r-- 1 root root 1461 Aug 24 10:39 cn={5}dyngroup.ldif
-rw-r--r-- 1 root root 2623 Aug 24 10:39 cn={6}inetorgperson.ldif
-rw-r--r-- 1 root root 2357 Aug 24 10:39 cn={7}java.ldif
-rw-r--r-- 1 root root 1280 Aug 24 10:39 cn={8}misc.ldif
-rw-r--r-- 1 root root 6259 Aug 24 10:39 cn={9}nis.ldif

6º) Importamos el ldif de zarafa:

# ldapadd -Y EXTERNAL -H ldapi:/// -f cn\=\{13\}zarafa.ldif

Esto se puede aplicar, como me ha pasado a mi, con el schema de freeradius o otros schemas.

enjoy 🙂

Freeradius stop on logger rotate

Otra entrada que es un apunte.

Cuando instalas el freeradius y lo dejas tal cual configurado, cuando hace el log rotate, se queda parado….. aquí explican el bug:

Freeradius stop

Para impedir que se quede parado, tras hacer el logrotate, hemos de modificar el siguiente fichero:


# nano /etc/logrotate.d/freeradius

Y ha de quedar tal que:

/var/log/freeradius/*.log {
weekly
rotate 52
compress
delaycompress
notifempty
missingok
postrotate
/etc/init.d/freeradius restart > /dev/null
endscript
}

Hemos de cambiar la línea

/etc/init.d/freeradius reload > /dev/null

a

/etc/init.d/freeradius restart > /dev/null

enjoy 😉

FreeRadius + Mysql + PPTPD en Debian.

Siguiendo al post anterior, ahora toca crear el servidor PPTPD, para por ejemplo, lanzar la vpn desde nuestro android.

Primero comprobamos si tenemos en el Kernel de nuestro linux, el soporte para MPPE, para ello:

# modprobe ppp-compress-18 && echo OK

Si sale OK, pues eso, ha ido bien…. ¿ y qué es eso de MPPE ?, pues nada, un protocolo de micro$oft para encriptar datos, léase:

http://en.wikipedia.org/wiki/Microsoft_Point-to-Point_Encryption

Y ojo, que tiene su propia RFC (O_o).

Ahora, instalamos el server pptpd en nuestro querido debian:

# apt-get install pptpd

Antes de empezar a configurar, hemos de tener claro:

1º) Pool de Ip’s que les asignaremos a los usuarios
2º) Dentro del Pool, las opciones de dns y demás que querremos usar para los clientes

Editamos el fichero /etc/pptpd.conf y lo vamos dejando tal que:

localip 192.168.2.13
remoteip 192.168.100.234-240

Donde localip, que con gran ojo avizor, deducimos que es la ip de nuestro servidor y, el que tenga la suerte de poder ponerle la ip pública directamente, pues eso que se lleva.

La remoteip, será el pool de IP’s que asignaremos a los usuarios remotos.

Guardamos los cambios, reinciamos el daemon pptpd y seguimos configurando y instalamos el paquete libradiusclient-ng2, que será el responsable de la relación entre pptpd y freeradius… para ello:

apt-get install libradiusclient-ng2

Y renombramos la carpeta para que quede más elegante:

mv /etc/radiusclient-ng/ /etc/radiusclient/

Creamos un fichero, que ya explicaremos la función:

echo “” > /etc/radiusclient/port-id-map

Ahora editaremos el fichero radiusclient.conf

# nano /etc/radiusclient/radiusclient.conf

Y lo dejamos tal que:

# General settings

# specify which authentication comes first respectively which
# authentication is used. possible values are: “radius” and “local”.
# if you specify “radius,local” then the RADIUS server is asked
# first then the local one. if only one keyword is specified only
# this server is asked.
auth_order radius

# maximum login tries a user has
login_tries 4

# timeout for all login tries
# if this time is exceeded the user is kicked out
login_timeout 60

# name of the nologin file which when it exists disables logins.
# it may be extended by the ttyname which will result in
# a terminal specific lock (e.g. /etc/nologin.ttyS2 will disable
# logins on /dev/ttyS2)
nologin /etc/nologin

# name of the issue file. it’s only display when no username is passed
# on the radlogin command line
issue /etc/radiusclient/issue

# RADIUS settings

# RADIUS server to use for authentication requests. this config
# item can appear more then one time. if multiple servers are
# defined they are tried in a round robin fashion if one
# server is not answering.
# optionally you can specify a the port number on which is remote
# RADIUS listens separated by a colon from the hostname. if
# no port is specified /etc/services is consulted of the radius
# service. if this fails also a compiled in default is used.
authserver localhost:1812

# RADIUS server to use for accouting requests. All that I
# said for authserver applies, too.
#
acctserver localhost:1812

# file holding shared secrets used for the communication
# between the RADIUS client and server
servers /etc/radiusclient/servers

# dictionary of allowed attributes and values
# just like in the normal RADIUS distributions
dictionary /etc/radiusclient/dictionary

# program to call for a RADIUS authenticated login
login_radius /usr/sbin/login.radius

# file which holds sequence number for communication with the
# RADIUS server
seqfile /var/run/radius.seq

# file which specifies mapping between ttyname and NAS-Port attribute
mapfile /etc/radiusclient/port-id-map

# default authentication realm to append to all usernames if no
# realm was explicitly specified by the user
# the radiusd directly form Livingston doesnt use any realms, so leave
# it blank then
default_realm

# time to wait for a reply from the RADIUS server
radius_timeout 10

# resend request this many times before trying the next server
radius_retries 3

# local address from which radius packets have to be sent
# bindaddr 0.0.0.0

# LOCAL settings

# program to execute for local login
# it must support the -f flag for preauthenticated login
login_local /bin/login

Definiremos nuestros servidores radius (modificando lo que está en negrita), con lo que toque.

Ahora definiremos la pre-shared key para los servidores radius:

nano /etc/radiusclient/servers

y colocamos nuestros datos:

#Server Name or Client/Server pair Key
#—————- —————
ip.de.nuestro.radius_server misuperclavemolona

Editamos el fichero pptpd-options

nano /etc/ppp/pptpd-options

Por ahora, nos vamos a centrar en pap / spap… una vez nos funcione, buscaremos otros métodos más seguros:

###############################################################################
# $Id: pptpd-options 4643 2006-11-06 18:42:43Z rene $
#
# Sample Poptop PPP options file /etc/ppp/pptpd-options
# Options used by PPP when a connection arrives from a client.
# This file is pointed to by /etc/pptpd.conf option keyword.
# Changes are effective on the next connection. See “man pppd”.
#
# You are expected to change this file to suit your system. As
# packaged, it requires PPP 2.4.2 and the kernel MPPE module.
###############################################################################

# Authentication

# Name of the local system for authentication purposes
# (must match the second field in /etc/ppp/chap-secrets entries)
name minombrechulo-del-servidor

# Optional: domain name to use for authentication
domain craem.net

# Strip the domain prefix from the username before authentication.
# (applies if you use pppd with chapms-strip-domain patch)
#chapms-strip-domain

# Encryption
# Debian: on systems with a kernel built with the package
# kernel-patch-mppe >= 2.4.2 and using ppp >= 2.4.2, …
# {{{
require-pap
require-chap
refuse-mschap

# Require the peer to authenticate itself using MS-CHAPv2 [Microsoft
# Challenge Handshake Authentication Protocol, Version 2] authentication.
# refuse-mschap-v2
# Require MPPE 128-bit encryption
# (note that MPPE requires the use of MSCHAP-V2 during authentication)
# refuse-mppe-128
# }}}

# Network and Routing

# If pppd is acting as a server for Microsoft Windows clients, this
# option allows pppd to supply one or two DNS (Domain Name Server)
# addresses to the clients. The first instance of this option
# specifies the primary DNS address; the second instance (if given)
# specifies the secondary DNS address.
# Attention! This information may not be taken into account by a Windows
# client. See KB311218 in Microsoft’s knowledge base for more information.
ms-dns 8.8.8.8
ms-dns 8.8.4.4

# If pppd is acting as a server for Microsoft Windows or “Samba”
# clients, this option allows pppd to supply one or two WINS (Windows
# Internet Name Services) server addresses to the clients. The first
# instance of this option specifies the primary WINS address; the
# second instance (if given) specifies the secondary WINS address.
#ms-wins 10.0.0.3
#ms-wins 10.0.0.4

# Add an entry to this system’s ARP [Address Resolution Protocol]
# table with the IP address of the peer and the Ethernet address of this
# system. This will have the effect of making the peer appear to other
# systems to be on the local ethernet.
# (you do not need this if your PPTP server is responsible for routing
# packets to the clients — James Cameron)
proxyarp

# Debian: do not replace the default route
nodefaultroute

# Logging

# Enable connection debugging facilities.
# (see your syslog configuration for where pppd sends to)
#debug

# Print out all the option values which have been set.
# (often requexsted by mailing list to verify options)
#dump

# Miscellaneous

# Create a UUCP-style lock file for the pseudo-tty to ensure exclusive
# access.
lock

# Disable BSD-Compress compression
nobsdcomp

mtu 1200
mru 1200
plugin radius.so
plugin radattr.so
lcp-echo-failure 50

Creamos un NAS en nuestro radius (lo vimos en el post anterior), reiniciamos el servicio pptpd y listo.

Probamos un cliente ( un android, por ejemplo)

Starting PPTP Daemon: pptpd.
root@radius_lan:/etc/ppp# tail -f /var/log/syslog
Oct 8 00:51:12 rlan pppd[2488]: Using interface ppp0
Oct 8 00:51:12 rlan pppd[2488]: Connect: ppp0 <--> /dev/pts/1
Oct 8 00:51:12 rlan pptpd[2486]: GRE: Bad checksum from pppd.
Oct 8 00:51:12 rlan pppd[2488]: Deflate (15) compression enabled
Oct 8 00:51:12 rlan pppd[2488]: Cannot determine ethernet address for proxy ARP
Oct 8 00:51:12 rlan pppd[2488]: local IP address 192.168.2.94
Oct 8 00:51:12 rlan pppd[2488]: remote IP address 192.168.100.234
Oct 8 00:51:26 rlan pptpd[2495]: MGR: Maximum of 200 connections reduced to 7, not enough IP addresses given
Oct 8 00:51:26 rlan pptpd[2496]: MGR: Manager process started
Oct 8 00:51:26 rlan pptpd[2496]: MGR: Maximum of 7 connections available
Oct 8 00:51:40 rlan pptpd[2486]: CTRL: EOF or bad error reading ctrl packet length.
Oct 8 00:51:40 rlan pptpd[2486]: CTRL: couldn’t read packet header (exit)
Oct 8 00:51:40 rlan pptpd[2486]: CTRL: CTRL read failed
Oct 8 00:51:40 rlan pptpd[2486]: CTRL: Reaping child PPP[2488]
Oct 8 00:51:40 rlan pptpd[2498]: CTRL: Client 192.168.2.68 control connection started
Oct 8 00:51:40 rlan pptpd[2498]: CTRL: Starting call (launching pppd, opening GRE)
Oct 8 00:51:40 rlan pppd[2499]: Plugin radius.so loaded.
Oct 8 00:51:40 rlan pppd[2499]: RADIUS plugin initialized.
Oct 8 00:51:40 rlan pppd[2499]: Plugin radattr.so loaded.
Oct 8 00:51:40 rlan pppd[2499]: RADATTR plugin initialized.
Oct 8 00:51:40 rlan pppd[2499]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so loaded.
Oct 8 00:51:40 rlan pppd[2499]: pppd 2.4.5 started by root, uid 0
Oct 8 00:51:40 rlan pppd[2499]: Using interface ppp1
Oct 8 00:51:40 rlan pppd[2499]: Connect: ppp1 <--> /dev/pts/2
Oct 8 00:51:40 rlan pptpd[2498]: GRE: Bad checksum from pppd.
Oct 8 00:51:40 rlan pppd[2499]: Deflate (15) compression enabled
Oct 8 00:51:40 rlan pppd[2499]: Cannot determine ethernet address for proxy ARP
Oct 8 00:51:40 rlan pppd[2499]: local IP address 192.168.2.13
Oct 8 00:51:40 rlan pppd[2499]: remote IP address 192.168.100.234

Y vemos el log del freeradius:

Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel
Listening on proxy address * port 1814
Ready to process requests.
rad_recv: Access-Request packet from host 127.0.0.1 port 33461, id=45, length=108
Service-Type = Framed-User
Framed-Protocol = PPP
User-Name = “angel”
CHAP-Challenge = 0x33c4ad40b662648176b52f85b7b47c47030561884ce3
CHAP-Password = 0x679fa22be2a3a09c79e7ff5f047edb60ae
Calling-Station-Id = “192.168.2.68”
NAS-IP-Address = 127.0.1.1
NAS-Port = 0

# Executing section authorize from file /etc/freeradius/sites-enabled/default
+- entering group authorize {…}
++[preprocess] returns ok
[chap] Setting ‘Auth-Type := CHAP’
++[chap] returns ok
++[digest] returns noop
[suffix] No ‘@’ in User-Name = “angel”, looking up realm NULL
[suffix] No such realm “NULL”
++[suffix] returns noop
[eap] No EAP-Message, not doing EAP
++[eap] returns noop
[files] users: Matched entry DEFAULT at line 172
++[files] returns ok
[sql] expand: %{User-Name} -> angel
[sql] sql_set_user escaped user –> ‘angel’
rlm_sql (sql): Reserving sql socket id: 3
[sql] expand: SELECT id, username, attribute, value, op FROM radcheck WHERE username = ‘%{SQL-User-Name}’ ORDER BY id -> SELECT id, username, attribute, value, op FROM radcheck WHERE username = ‘angel’ ORDER BY id
[sql] User found in radcheck table
[sql] expand: SELECT id, username, attribute, value, op FROM radreply WHERE username = ‘%{SQL-User-Name}’ ORDER BY id -> SELECT id, username, attribute, value, op FROM radreply WHERE username = ‘angel’ ORDER BY id
[sql] expand: SELECT groupname FROM radusergroup WHERE username = ‘%{SQL-User-Name}’ ORDER BY priority -> SELECT groupname FROM radusergroup WHERE username = ‘angel’ ORDER BY priority
rlm_sql (sql): Released sql socket id: 3
++[sql] returns ok
++[expiration] returns noop
++[logintime] returns noop
[pap] WARNING: Auth-Type already set. Not setting to PAP
++[pap] returns noop
Found Auth-Type = CHAP
# Executing group from file /etc/freeradius/sites-enabled/default
+- entering group CHAP {…}
[chap] login attempt by “angel” with CHAP password
[chap] Using clear text password “password_chulo” for user angel authentication.
[chap] chap user angel authenticated succesfully
++[chap] returns ok
# Executing section post-auth from file /etc/freeradius/sites-enabled/default
+- entering group post-auth {…}
[sql] expand: %{User-Name} -> angel
[sql] sql_set_user escaped user –> ‘angel’
[sql] expand: %{User-Password} ->
[sql] … expanding second conditional

[sql] expand: %{Chap-Password} -> 0x679fa22be2a3a09c79e7ff5f047edb60ae
[sql] expand: INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( ‘%{User-Name}’, ‘%{%{User-Password}:-%{Chap-Password}}’, ‘%{reply:Packet-Type}’, ‘%S’) -> INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( ‘angel’, ‘0x679fa22be2a3a09c79e7ff5f047edb60ae’, ‘Access-Accept’, ‘2012-10-08 00:54:23’)
rlm_sql (sql) in sql_postauth: query is INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( ‘angel’, ‘0x679fa22be2a3a09c79e7ff5f047edb60ae’, ‘Access-Accept’, ‘2012-10-08 00:54:23’)
rlm_sql (sql): Reserving sql socket id: 2
rlm_sql (sql): Released sql socket id: 2
++[sql] returns ok
[sql_log] Processing sql_log_postauth
[sql_log] expand: %{User-Name} -> angel
[sql_log] expand: %{%{User-Name}:-DEFAULT} -> angel
[sql_log] sql_set_user escaped user –> ‘angel’
[sql_log] WARNING: Deprecated conditional expansion “:-“. See “man unlang” for details
[sql_log] … expanding second conditional
[sql_log] expand: Chap-Password -> Chap-Password
[sql_log] expand: INSERT INTO radpostauth (username, pass, reply, authdate) VALUES (‘%{User-Name}’, ‘%{User-Password:-Chap-Password}’, ‘%{reply:Packet-Type}’, ‘%S’); -> INSERT INTO radpostauth (username, pass, reply, authdate) VALUES (‘angel’, ‘Chap-Password’, ‘Access-Accept’, ‘2012-10-08 00:54:23’);
[sql_log] expand: /var/log/freeradius/radacct/sql-relay -> /var/log/freeradius/radacct/sql-relay
++[sql_log] returns ok
++[exec] returns noop
Sending Access-Accept of id 45 to 127.0.0.1 port 33461
Framed-Protocol = PPP
Framed-Compression = Van-Jacobson-TCP-IP

Finished request 0.
Going to the next request
Waking up in 4.9 seconds.
Invalid packet code 4 sent to authentication port from client port 51954 : IGNORED
Waking up in 4.9 seconds.
Cleaning up request 0 ID 45 with timestamp +8
Ready to process requests.
Invalid packet code 4 sent to authentication port from client port 51954 : IGNORED
Ready to process requests.

Enjoy your server 😉

Freeradius + mysql en debian squeeze

Hoy toca instalar un freeradius en un cliente, para authenticar los accesos de unos hotspots Mikrotik.

Para la parte gráfica, usaremos el DaloRadius… de esta manera, no tendremos que andar con los ficheros de texto.

Suponemos que tenemos instalado ya nuestro Debian Squeeze y, vamos a instalar unos paquetes:


# aptitude install mysql-server php5 php5-mysql php5-gd php-pear php-db freeradius freeradius-mysql subversion

Creamos usuario para mysql y la bbdd para radius:


# mysql -u root -ppassword
mysql> GRANT ALL PRIVILEGES ON *.* TO 'radius'@'%' IDENTIFIED BY 'radius' WITH GRANT OPTION;
FLUSH PRIVILEGES;
mysql> create database radius;

Ahora bajamos el DaloRadius, en la carpeta /usr/src:


# cd /usr/src
# svn co https://daloradius.svn.sourceforge.net/svnroot/daloradius/trunk daloradius

Ahora movemos los directorios:


# cp daloradius/ /var/www -R
# chown www-data:www-data /var/www/daloradius -R
# chmod 644 /var/www/daloradius/library/daloradius.conf.php

Creamos la estructura de la BBDD de radius:


root@radius:/var/www/daloradius/contrib/db# mysql -u radius -pradius radius < fr2-mysql-daloradius-and-freeradius.sql

Editamos el fichero de configuración de daloRadius, para que se conecte a mysql:


# nano /var/www/daloradius/library/daloradius.conf.php

$configValues['CONFIG_DB_ENGINE'] = 'mysql';
$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_PORT'] = '3306';
$configValues['CONFIG_DB_USER'] = 'radius';
$configValues['CONFIG_DB_PASS'] = 'radius';
$configValues['CONFIG_DB_NAME'] = 'radius';

Ahora vamos modificando los ficheros de freeradius, para que se conecte a mysql.

En el directorio /etc/freeradius, editamos sql.conf y lo dejamos tal que:


sql {
#
# Set the database to one of:
#
# mysql, mssql, oracle, postgresql
#
database = "mysql"

#
# Which FreeRADIUS driver to use.
#
driver = "rlm_sql_${database}"

# Connection info:
server = "localhost"
#port = 3306
login = "radius"
password = "radius"

El siguiente paso, es que las consultas de usuarios, en vez de mirar en los ficheros locales, haga las consultas en las tablas de mysql. Para ello, modificaremos el fichero:


root@radius:/etc/freeradius/sites-enabled# nano default

Y modificamos:

### authorization Section
#
# Look in an SQL database. The schema of the database
# is meant to mirror the "users" file.
#
# See "Authorization Queries" in sql.conf
sql

### accounting section
#
# Log traffic to an SQL database.
#
# See "Accounting queries" in sql.conf
sql

Y en el fichero /etc/freeradius/radiusd.conf, habilitamos la parte de sql:


# Include another file that has the SQL-related configuration.
# This is another file only because it tends to be big.
#
$INCLUDE sql.conf

Por último, modificamos el fichero clients.conf, con el NAS localhost y una pass para probar .... (nas := network access server 😉 ) y lo dejamos tal que:


# -*- text -*-
##
## clients.conf -- client configuration directives
##
## $Id$

#######################################################################
#
# Define RADIUS clients (usually a NAS, Access Point, etc.).

client localhost {
ipaddr = 127.0.0.1
secret = testing123
nastype = other # localhost isn't usually a NAS...
}

Creamos ahora, desde la interfaz daloRadius, un usuario, para ello, accedemos al daloradius wía web:

http://ip.del.servidor.radius/daloradius

Y nos aparecerá algo tal que:

Usuario: administrator
pass: radius

En el apartado Management / Users , hacemos click en New User

Creamos un usuario, con su password y lo probaremos en la consola.

Paramos el servicio freeradius


# /etc/init.d/freeradius stop

Lanzamos el servicio en modo debug:


# freeradius -X

............
Module: Checking session {...} for more modules to load
Module: Checking post-proxy {...} for more modules to load
Module: Checking post-auth {...} for more modules to load
} # modules
} # server
radiusd: #### Opening IP addresses and Ports ####
listen {
type = "auth"
ipaddr = *
port = 0
}
listen {
type = "acct"
ipaddr = *
port = 0
}
listen {
type = "auth"
ipaddr = 127.0.0.1
port = 18120
}
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel
Listening on proxy address * port 1814
Ready to process requests.

Y ahora desde otra consola, hacemos una prueba con la utilidad radtest :


root@radius:~# radtest pruebas pruebas01 localhost:1812 0 testing123
Sending Access-Request of id 49 to 127.0.0.1 port 1812
User-Name = "pruebas"
User-Password = "pruebas01"
NAS-IP-Address = 127.0.1.1
NAS-Port = 0
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=49, length=20
root@radius:~#

Nuestros datos:

Username: pruebas
pass:pruebas01
NasKey:testing123 (lo hemos puesto en el apartado nas, anteriormente, en localhost
Puerto Radius: 1812

Y el freeradius, nos responde con:


Ready to process requests.
rad_recv: Access-Request packet from host 127.0.0.1 port 37927, id=49, length=59
User-Name = "process"
User-Password = "control10"
NAS-IP-Address = 127.0.1.1
NAS-Port = 0
# Executing section authorize from file /etc/freeradius/sites-enabled/default
+- entering group authorize {...}
++[preprocess] returns ok
++[chap] returns noop
++[mschap] returns noop
++[digest] returns noop
[suffix] No '@' in User-Name = "pruebas", looking up realm NULL
[suffix] No such realm "NULL"
++[suffix] returns noop
[eap] No EAP-Message, not doing EAP
++[eap] returns noop
++[files] returns noop
[sql] expand: %{User-Name} -> pruebas
[sql] sql_set_user escaped user --> 'pruebas'
rlm_sql (sql): Reserving sql socket id: 4
[sql] expand: SELECT id, username, attribute, value, op FROM radcheck WHERE username = '%{SQL-User-Name}' ORDER BY id -> SELECT id, username, attribute, value, op FROM radcheck WHERE username = 'pruebas' ORDER BY id
[sql] User found in radcheck table
[sql] expand: SELECT id, username, attribute, value, op FROM radreply WHERE username = '%{SQL-User-Name}' ORDER BY id -> SELECT id, username, attribute, value, op FROM radreply WHERE username = 'pruebas' ORDER BY id
[sql] expand: SELECT groupname FROM radusergroup WHERE username = '%{SQL-User-Name}' ORDER BY priority -> SELECT groupname FROM radusergroup WHERE username = 'pruebas' ORDER BY priority
rlm_sql (sql): Released sql socket id: 4
++[sql] returns ok
++[expiration] returns noop
++[logintime] returns noop
++[pap] returns updated
Found Auth-Type = PAP
# Executing group from file /etc/freeradius/sites-enabled/default
+- entering group PAP {...}
[pap] login attempt with password "pruebas01"
[pap] Using clear text password "pruebas01"
[pap] User authenticated successfully
++[pap] returns ok
# Executing section post-auth from file /etc/freeradius/sites-enabled/default
+- entering group post-auth {...}
++[exec] returns noop
Sending Access-Accept of id 49 to 127.0.0.1 port 37927
Finished request 0.
Going to the next request
Waking up in 4.9 seconds.
Cleaning up request 0 ID 49 with timestamp +177
Ready to process requests.

Y vemos como hace la consulta en mysql.

Enjoy your radius 😉