Personal #radius#ssl#wifi 7 min

Secure wi-fi Net : freeRadius + WRT54G = 802.1x (WPA-radius EAP/TLS)

Traducció de l’original en anglès. Llegeix-lo en: CastellanoEnglish

wifi.gif

Volia fer una xarxa wifi segura d'un nivell alt, no com es fa ara amb WEP i altres ximpleries. Així que vaig instal·lar un servidor FreeRadius per treballar amb un Linksys WRT54G. La idea bàsica és instal·lar un HyperWRT al WRT54G (consell del Pof). Després el configurem com a WPA-Radius cap al firewall on vaig instal·lar Freeradius. Aquest darrer pas és opcional perquè el firmware estàndard del WRT54G suporta WPA-Radius.

Esquema de la xarxa; fixeu-vos en el firewall i l'AP, la resta no és important:

wpa-eaptls.gif

Per configurar-ho tot només he seguit les instruccions de l'802.1x HOWTO. De totes maneres us he fet una petita guia:

  • Instal·lar Freeradius al firewall: emerge freeradius

  • Configurar Freeradius per treballar amb EAP/TLS

  • Generar els certificats

  • Comprovar que el freeradius funciona correctament

  • Configurar l'AP (Linksys WRT54G)

  • Configurar els clients amb Windows XP amb SP2

  • Configurar els clients Linux

Els fitxers de configuració que he fet servir per al freeradius són aquests:

  • /etc/raddb/radiusd.conf: Fitxer de configuració general del Radius, hi hem de definir els sistemes d'autenticació i altres coses que volem fer servir. Hi ha moltes parts que no he utilitzat, així que les he deixat tal com venien. Vull agrair al Pof que em deixés els seus fitxers de configuració per poder configurar els meus.

  • /etc/raddb/clients.conf: IPs i sistemes de xarxa que poden ser clients radius; en el nostre cas l'AP (172.16.1.253).

Tot i el poder del radius, la documentació i la manca de temps per experimentar us deixo això, però si algú ho pot fer millor m'agradaria saber-ho.

Per a la generació dels certificats la idea és fer-los a partir d'una entitat certificada, però això només passa a les pel·lícules i a les grans empreses. Agafem OpenSSL i fem la nostra feina. Si encara no el tens, ja ho saps: emerge openssl. És clar que no som bons en PKI i altres coses semblants, així que és millor aprendre amb els scripts de freeradius i openssl, perquè amb algunes modificacions podem crear certificats per treballar amb les nostres xarxes wifi segures.

Com us deia, farem servir els scripts de freeradius i openssl per generar els certificats, així que primer de tot anem a la carpeta del freeradius on hi ha una carpeta anomenada "scripts" amb: CA.certs, certs.sh i xpextensions. Us recomano revisar l'ordre de les ubicacions dins dels scripts perquè jo hi vaig tenir problemes. Si us fa mandra mirar els fitxers, podeu comprovar els meus en aquest petit paquet: certs.tar.gz, aquests fitxers estan modificats per treballar des de la mateixa carpeta on estem treballant, us recomano crear una carpeta nova i buida. Un cop identificats els fitxers, hem de tenir a la PATH l'script CA.pl, que és un script de perl, però no sempre es copia a la PATH, així que el vaig copiar a /usr/bin i el vaig esborrar després de generar els certificats. També he inclòs el fitxer al paquet, si us fa mandra...

Un cop tinguem totes les coses en una carpeta a punt per treballar podem editar CA.certs per incloure la nostra informació a les variables de l'inici del fitxer. No cal canviar més variables, es fa automàticament. No us oblideu de la contrasenya perquè la necessitarem quan configurem el servidor i els clients.

Per generar els certificats només cal fer:

# ./certs.sh

i la sortida serà una cosa com aquesta:

Generating DH parameters, 512 bit long safe prime, generator 2<br>This is going to take a long time<br>........................+......................................................+...........+................................+..........+.......................+...+...........................................+...............................+............+..............+.................................+.......+..+.................................................+....+....................+.........................................+..+......+................................................+........+.....+...............+...........+.+..................+...........+..................................................+............+......+.+.................+.+.........................+....+................+....+....+.....+.........................+............+......+.+..........................................................+..+...........................................+.........................+.............................+..................................................+...+...++*++*++*++*++*++*<br>  See the 'certs' directory for the certificates.<br>  The 'certs' directory should be copied to .../etc/raddb/<br>  All passwords have been set to 'whatever'

No us preocupeu pels missatges, només en cas que hi hagi algun error. Ara tindreu una carpeta nova dins de la carpeta on sou, anomenada certs, i a dins hi trobareu tots els certificats per al servidor i per al client. Us recomano copiar el contingut de ./certs a /etc/raddb/certs, així no haureu de canviar els fitxers de configuració que us dono.

La cosa més important ara és comprovar primer els fitxers de configuració que us he donat i comprovar que el servidor radius arrenca sense problemes, cosa que malauradament no passa mai. Pel que fa al radiusd.conf, no crec que hi tingueu molts problemes, només comproveu que els camins cap als certificats són els correctes que acabeu de crear. Comproveu també el paràmetre: **private_key_password = **whatever. Canvieu 'whatever' per la vostra contrasenya, la que heu utilitzat a la variable PASSWORD dins del fitxer CA.certs. Si no ho feu, quan arrenqueu el dimoni amb radiusd -X us demanarà una clau que s'utilitza per xifrar simètricament els fitxers amb una clau privada, que és la contrasenya de què us parlo. Si no ho feu, quan feu /etc/init.d/radiusd start tindreu un error perquè el servidor no podrà fer servir les claus per accedir als certificats.

Només cal fer: radiusd -X i si obteniu la següent sortida:

Ready to process requests.

tot funciona bé. Només cal fer CTRL+C i arrencar el dimoni de Gentoo (/etc/init.d/radiusd start) o deixar-lo tal com està en un terminal client, així podeu veure els registres que es generen per comprovar si tot funciona bé. Si voleu comprovar els registres de l'historial mentre el dimoni està engegat, els trobareu a /var/log/radius/. Els registres de l'arrencada del dimoni són a startup.log i els de les connexions a radius.log. Per veure el registre en temps real només cal fer: tail -f /var/log/raddb/radius.log

Abans de configurar els usuaris heu de configurar l'AP com a client radius. Podeu configurar l'AP com vulgueu, però jo el vaig configurar com a router entre dues xarxes; la xarxa dels usuaris amb DHCP (192.168.2.0/24) i l'anomenada Internet per l'AP (172.16.1.253). M'agrada configurar així la xarxa; un cable que va al firewall on es pot comunicar amb el freeRadius. Per exemple; la interfície del firewall amb IP 172.16.1.254 i la interfície 'Internet' del WRT54G amb IP 172.16.1.253. Després heu d'assegurar-vos que la IP està permesa per treballar amb radius editant el fitxer /etc/raddb/clients.conf com a l'exemple següent:

client 172.16.1.253/32 {<br>        secret          = SharedSecret99<br>        shortname       = localhost<br>}

Vegeu que aquí apareix una altra contrasenya, aquesta 'pre-shared key' l'utilitzen el client WPA (WRT54G) i el servidor radius (freeRadius) per xifrar les seves comunicacions. Després heu d'assegurar-vos que aquesta clau està posada a la configuració de l'AP. Aquí us adjunto una captura de pantalla de com ha de ser la configuració de seguretat wireless de l'AP per treballar amb el servidor radius:

wpa-radius.jpg
Configuració WPA-Radius al WRT54G

Per a la configuració del client Windows, primer de tot heu de comprovar si la targeta de xarxa wifi té el firmware correcte per treballar amb WPA amb EAP/TLS. Si no ho sabeu, feu servir el manual següent de com configurar un WXP i si no trobeu les opcions que us mostro és que la vostra targeta no és vàlida. Només ho he provat en un WXP SP2; per a tota la resta, no ho sé.

He fet un fitxer PDF amb moltes captures de pantalla per configurar fàcilment el client WXP. Heu d'instal·lar dos fitxers de certificat; root.der i root.p12. Us els hauríeu d'haver creat abans i els podeu trobar a /etc/raddb/certs. Us recomano copiar aquests fitxers en un pendrive i fer-lo servir per a tots els clients.

Com instal·lar els clients EAP/TLS amb Windows XP SP2 en format PDF. Aquest document està basat en: HOWTO: configuració d'EAP//TLS per a FreeRADIIUS i Wiindows XP Supplliicant també en format PDF.

Pel que fa a la configuració de Linux; encara no ho he provat perquè el firmware de la meva targeta wifi PCMCIA és antic. Però provaré la targeta integrada al meu portàtil que funciona amb els controladors Linux ndiswrapper o linuxant, tots dos preparats per usar wap_suplicant, necessari per a l'autenticació WPA/TLS en una màquina Linux. Quan arribi a aquest punt no us preocupeu, us ho explicaré. No tinc ganes de treballar gaire amb Windows, em poso nerviós a la feina veient aquest caos.

Us adjunto algunes referències que he fet servir i que em van ajudar:

  • 8021X-HOWTO - Aquest document descriu el programari i els procediments per configurar i utilitzar el control d'accés a la xarxa basat en ports IEEE 802.1X fent servir Xsupplicant com a suplicant i FreeRADIUS com a servidor d'autenticació de backend.

  • Configuració de l'autenticació FreeRADIUS/WinXP - Aquest apunt descriu com construir un servidor FreeRADIUS per a l'autenticació TLS i PEAP, i com configurar els clients (suplicants) de Windows XP. El servidor està configurat per a una xarxa domèstica (o de proves).

  • HOWTO sobre l'autenticació EAP/TLS entre FreeRADIUS i XSupplicant - Aquest document descriu com configurar una autenticació criptogràfica forta entre XSupplicant i FreeRADIUS. Això s'ac aconsegueix utilitzant part de l'autenticació 802.1x per a xarxa sense fils. En particular fa servir l'extensió EAP/TLS i el handshake TLS.

Pretenc que això ajudi a tanta gent com sigui possible. Gràcies per la vostra paciència.

39 comentaris

Els comentaris del blog antic, tal com es van escriure. Els comentaris estan tancats.

  1. Otto Kucera

    hi!

    your manunal helped me a lot. it tryed to read your sample configs but the links does not work. could you send the sample config per email? my adress: ok@geeks.at

    regards,

    otto

  2. —

    Please try it, now.

    Thank you.

  3. satrio

    i tried to download your certicficate...but its not valid...do you have the latest?

  4. satrio

    i would like to ask you a couples of questions:

    1. in your client.conf your secret key is SharedSecret99 but in your radiusd.conf your private_key_password is whatever, is it ok to have different?

    2. what is this mean "ippool main_pool {

    range-start = 192.168.1.4

    range-stop = 192.168.1.254

    netmask = 255.255.255.0

    cache-size = 800

    session-db = ${raddbdir}/db.ippool

    ip-index = ${raddbdir}/db.ipindex

    override = no"?

    3. is your radius connected to database to store the user and password list?

    im sorry to ask you a lot of questions, its just im doing my thesis to build a radius server and the access point is wrt54g also...but it doesnt work, and my deadline is coming up.will you help me?

  5. satrio

    ad_recv: Access-Request packet from host 192.168.1.1:2061, id=0, length=166

    User-Name = "linksys"

    NAS-IP-Address = 192.168.1.1

    Called-Station-Id = "0014bf04a514"

    Calling-Station-Id = "000e3574ca4d"

    NAS-Identifier = "0014bf04a514"

    NAS-Port = 51

    Framed-MTU = 1400

    State = 0xb23b333336fba1b91206537df02cd417

    NAS-Port-Type = Wireless-802.11

    EAP-Message = 0x020300210d8000000017150301001208f9e73fcdfba3b0ed5dd3c41101dd967eb1

    Message-Authenticator = 0xc0f6b9b2c301f8a7f362abe41fad9227

    Processing the authorize section of radiusd.conf

    modcall: entering group authorize for request 27

    modcall[authorize]: module "preprocess" returns ok for request 27

    rlm_eap: EAP packet type response id 3 length 33

    rlm_eap: No EAP Start, assuming it's an on-going EAP conversation

    modcall[authorize]: module "eap" returns updated for request 27

    rlm_realm: No '/' in User-Name = "linksys", looking up realm NULL

    rlm_realm: No such realm "NULL"

    modcall[authorize]: module "realmslash" returns noop for request 27

    rlm_realm: No '@' in User-Name = "linksys", looking up realm NULL

    rlm_realm: No such realm "NULL"

    modcall[authorize]: module "suffix" returns noop for request 27

    users: Matched entry DEFAULT at line 96

    modcall[authorize]: module "files" returns ok for request 27

    modcall: group authorize returns updated for request 27

    rad_check_password: Found Auth-Type EAP

    auth: type "EAP"

    Processing the authenticate section of radiusd.conf

    modcall: entering group authenticate for request 27

    rlm_eap: Request found, released from the list

    rlm_eap: EAP/tls

    rlm_eap: processing type tls

    rlm_eap_tls: Authenticate

    rlm_eap_tls: processing TLS

    rlm_eap_tls: Length Included

    eaptls_verify returned 11

    eaptls_process returned 7

    rlm_eap_tls: Received unexpected tunneled data after successful handshake.

    rlm_eap: Handler failed in EAP/tls

    rlm_eap: Failed in EAP select

    modcall[authenticate]: module "eap" returns invalid for request 27

    modcall: group authenticate returns invalid for request 27

    auth: Failed to validate the user.

    Delaying request 27 for 1 seconds

    Finished request 27

    Going to the next request

    Waking up in 6 seconds...

    --- Walking the entire request list ---

    Sending Access-Reject of id 0 to 192.168.1.1:2061

    EAP-Message = 0x04030004

    Message-Authenticator = 0x00000000000000000000000000000000

    Cleaning up request 27 ID 0 with timestamp 43dc0fa0

  6. satrio

    i still cannot login from my laptop..i followed your steps...

    thats the message on the server, do you know why?

    if you dont mind, would you sent me your whole conf file? just the raddb folder would be help me a lot...

    thx man

  7. —

    [3] my certificate is out of date from 25th of January. If you wanna another certificate please make your own like is indicated in this post. If you have any problem in the process may be I can help you.

  8. —

    [4]

    1. isn't the same password, whatever is a symetric password to access to certificate. SharedSecret99 is the password to establish a secure path over local network to connect my AP to my RADIUS server.

    2. if you look in default configuration file (radiusd.conf) you can see this information about this part of config file:

    # Do server side ip pool management. Should be added in post-auth and

    # accounting sections.

    #

    # The module also requires the existance of the Pool-Name

    # attribute. That way the administrator can add the Pool-Name

    # attribute in the user profiles and use different pools

    # for different users. The Pool-Name attribute is a *check* item not

    # a reply item.

    3. my passwords are stored in plain text file (/etc/raddb/users)

  9. —

    [6] my /etc/raddb folder is by default except my radiusd.conf and clients.conf, that files are attached in this post.

    Maybe you have a problem with you radius version I only tried my configuration with this version:

    radiusd -v

    radiusd: FreeRADIUS Version 1.0.5, for host , built on Oct 1 2005 at 18:22:05

    Copyright (C) 2000-2003 The FreeRADIUS server project.

    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.

    For more information about these matters, see the file named COPYRIGHT.

    If you install this version of radius and re-generate your certificates. It works sure then the problem only can be your firmware in AP or your client configuration.

  10. satrio

    im sorry to message you this much, coz i really2 need help.

    after you saw my log, you probably notice this:

    rlm_eap_tls: Received unexpected tunneled data after successful handshake.

    rlm_eap: Handler failed in EAP/tls

    rlm_eap: Failed in EAP select

    do you know what and why is that?

    do want me to show you my radiusd.conf, users.conf, clients.conf, eap.conf files?

    my radius version is 1.02..is that ok?

  11. —

    I'm looking for your error message in goolge and I found this (solution) Received unexpected tunneled data after successful handshake. As I said before you have a problem with your certificates.

    Your radius version is older than mine, I don't know if your version has any important diferent working with certificates. Maybe upgrade your version to 1.0.5 is a good idea.

    IMHO you have not to modify your config files only upgrade version of radius and try it, then if it doesn't work regenerate your certificates like my post or like EAPTLS.pdf document.

    Good luck

  12. Satrio

    many times i tried to generate my certificate but its always not valid. the message was digital signature is not valid and the last time i tried the certificate is not valid.

    do you have any idea what is wrong?

  13. Satrio

    should i download and install the hyperWRT?

  14. —

    what is your firmware? as you can see in the post my firmware is hyperWRT 2.0b3

  15. Satrio

    thx to you, now my radius is working.but when my laptop trying to connect, the radius didnt ask about username and password. the radius only check the certificate. how to make login window pop up on my laptop...and the radius will check if it is a correct login and password or not?

  16. —

    [15] My auth system works as you say, but if you want an user authentication you need to modify a little your radiusd.conf file. If you want you can try to use EAP/TTLS insted of EAP/TLS it supports users authentication, accounting and anything else.

    Now I don't remember all you need to do user authentication because I configure it for 1 year ago. And I don't have this details now. But if you get this please send me this information to extend my post.

  17. Satrio

    hello...my radius is running perfectly...but the radwho is empty....any idea why?

  18. Carita

    milieu etrange http://www.milieu-etrange.0chattes.com [URL=http://www.milieu-etrange.0chattes.com]milieu etrange[/URL]

  19. marcelo

    Hi people i´m from chile your how to was great I spent lot of time trying to find a good how to. sorry about english bye

  20. zmkgpqfx

    [URL=http://yooukenv.com]zbcofxmj[/URL] huvfptce jfhaclmt http://ivzuzguk.com omzgooaf eggkhbwj

  21. Yusri

    Hi,

    My questions.

    1) Why do you need to upgrade the firmware in the AP? Can you just use an unupgrade AP?

    2) How can i make the radius accepts certificate and mac address for authentication?

  22. —

    [21]

    1) It's not necessary upgrade the firmware. I upgrade it for other reasons, like access to AP via telnet or SSH.

    2) IMHO it's not possible to authenticate the AP with Radius via Certificate and MAC.

  23. Yusri

    I follow your guide but i got an error in WXP (system event viewer).

    "The certificate received from the remote server was issued by an untrusted certificate authority. Because of this, none of the data contained in the certificate can be validated. The SSL connection request has failed. The attached data contains the server certificate."

    My radius keep sending a access-challenge.

    What exactly i miss? Is it problem with the certificate? I use freeradius in Fedora core 9.

    How can i solve this problem?

  24. —

    [23]

    Are you installed root certificate of certificate authority?

  25. Yusri

    Yes, exactly what u wrote in this step.

    I tried to find someones tutorial and i found that somes use root.der and cert-clt.p12. But you use root.de and root.p12 in WXP.

    So, whats the different? Does it effect my authetication session?

  26. —

    [25]

    It's the same root.der is the root certificate of Certificate authorithy and root.p12 is a client certificate. You can see my cookbook for EAP-TTLS maybe it can help you: cookbook eap-ttls

  27. Yusri

    Suddenly, i successfully configure radius to accept WAP+EAP TLS authentication. I dont know how. Just followed your steps you gave.

    The problem now is, the authentication only depend on EAP. How can i make a control access for the users that listed in users file and SQL? I failed to do this.

  28. —

    [27]

    If you want authenticate user you need TTLS no TLS. You can see this: Securing wi-fi net with EAP/TTLS it is a wiki entry but If you need help you can ask me all you want because I write this cookbook.

  29. Yusri

    My next problem, if you dont mind.

    User authentication is a success. But any invalid authentication, freeradius still accept. How can i reject invalid or unauthorize user. I tried both on file and sql, but failed. Help me. Hope this is the last. :)

  30. —

    [29]

    What is your WPA supplicant client? IMHO this a problem of a WPA supplicant it is not a problem of server. You can trace authorization via log file.

  31. Yusri

    I think my problem is the same with Satrio (above). Its only checked certificate. It checked username but wether its valid or not, the system still aceept it because of the certificate. Im using XP supplicant SP1 with wifi patch.

  32. —

    [31]

    You need third party supplicant XP doesn't support TTLS itself. Your problem is that only is only working your TLS part not TTLS. You doesn't request your PAP or CHAP auth because Windows doesn't require it.

  33. Yusri

    GREAT! It is a success. I used SecureW2. Works fine.

    1 more thing, i also like to validate the mac address along with username, so how can i write ni "users" and "sql"?

  34. —

    [33]

    I don't know how can you validate MAC address too. I never do that.

  35. Yusri

    Oriol, meet u again.

    I successfully configure radius for EAP/TTLS. What i did was using SecureW2 as a supplicant. I set it to authenticate the username and validate the MAC address.

    I tried to make security testing. I removed the certificate in the client (XP) and made the wifi connection again. The connection was a success.

    In theory, the wifi connection also involve certificate to authenticate. So, without certificate, authentication will fail. Am i right? It seem like my client dont need any certificate. What to make radius server reject client that not has certificate?

  36. —

    [35]

    I don't know what is your problem, because I don't use windows. In my linux boxes when I remove client certificate it doesn't work. May be you have a mistake in your radiusd.conf file...

  37. Jordan

    Is it possible to include in freeradius configuration checking mac adress (not in WRT54)?

  38. —

    [37]

    May be, but I never find it.

  39. sdsd