Setting Up A FreeRadius Based AAA Server With MySQL & Management With Daloradius

Submitted by awan (Contact Author) (Forums) on Fri, 2008-08-15 18:48. :: Ubuntu

Setting Up A FreeRadius Based AAA Server With MySQL & Management With Daloradius

This tutorial explains how you can set up a FreeRadius (1.1.7) server with Wifi authentication and accounting in conjunction with MySQL & web management with Daloradius on Ubuntu 8.04 LTS Server Edition This howto should work for a novice. Production deployment is also possible with minor tweaking. But as usual I do not guarantee anything & take no responsibilities if something goes wrong.

(For a basic how-to refer to the doc http://www.howtoforge.com/wifi-authentication-accounting-with-freeradius-on-centos5.)

Following steps are involved:

  1. Building Ubuntu 8.04 .debs (for eap/ttls support)
  2. Installing the binary packages
  3. Configuring the FR with MySQL
  4. Setting up web management with Daloradius

 

Step 1- Building Ubuntu 8.04. packages

 Note: Those who don't need openssl/tls/ttls (certificates etc..) just fetch the FR packages from ubuntu repos with apt-get & skip to step 3.

Before building the FreeRadius Ubuntu 8.04 package we have to apt-get some packages, necessary for the build process.

sudo su -

apt-get install   debhelper  libltdl3-dev libpam0g-dev \
libmysqlclient15-dev build-essential libgdbm-dev \
libldap2-dev libsasl2-dev libiodbc2-dev libkrb5-dev snmp \
autotools-dev dpatch  libperl-dev libtool dpkg-dev libpq-dev \
libsnmp-dev libssl-dev 

Get hold of the FreeRadius sources and start building the package like given below.

cd ~
apt-get source freeradius

Note: It is recommended that you carry this building process on a non-production server & move the final binary packages over to the production server. But it isn't mandatory if you know what you're doing.

cd  freeradius-1.1.7/

Edit rule file (debian/rules):

vi debian/rules

Now search for these lines:

        --without-rlm_eap_tls \
                --without-rlm_eap_ttls \
                --without-rlm_eap_peap \

and change them to look like this.

 --with-rlm_eap_tls \
                   --with-rlm_eap_ttls \
                   --with-rlm_eap_peap \ 
 

Also in the same file replace the text " --without-openssl  " with " --with-openssl  "

Now search for these lines and delete them.

for pkg in $(shell grep ^Package debian/control | awk '{print $$2}') ; d
   o \
     if dh_shlibdeps -p $$pkg -- -O | grep -q libssl; then \
       echo "$$pkg links to openssl" ;\
       exit 1 ;\
     fi ;\
   done  

Save changes and quit vi. Now edit the control file (debian/control):

vi debian/control

Search for the line:

Build-Depends: debhelper (>= 5), libltdl3-dev, libpam0g-dev, libmysqlclient15-dev | libmysqlclient-dev, libgdbm-dev, libldap2-dev, libsasl2-dev, libiodbc2-dev, libkrb5-dev, snmp, autotools-dev, dpatch (>= 2), libperl-dev, libtool, dpkg-dev (>= 1.13.19), libpq-dev, libsnmp-dev

 and append libssl-dev to the end of this line so that it looks like this.

Build-Depends: debhelper (>= 5), libltdl3-dev, libpam0g-dev, libmysqlclient15-dev | libmysqlclient-dev, libgdbm-dev, libldap2-dev, libsasl2-dev, libiodbc2-dev, libkrb5-dev, snmp, autotools-dev, dpatch (>= 2), libperl-dev, libtool, dpkg-dev (>= 1.13.19), libpq-dev, libsnmp-dev, libssl-dev

Save the changes and quit vi.

Assuming you are here  ~/freeradius-1.1.7. Start building packages:

dpkg-buildpackage -rfakeroot

Note: You still might require some packages for these. apt-get/aptitiude them & rerun the rebuild process.

After a while (depending on your system) you should have some .deb files in the home directory.

freeradius_1.1.7-1build4_i386.deb
freeradius-dbg_1.1.7-1build4_i386.deb
freeradius-dialupadmin_1.1.7-1build4_all.deb
freeradius-iodbc_1.1.7-1build4_i386.deb
freeradius-krb5_1.1.7-1build4_i386.deb
freeradius-ldap_1.1.7-1build4_i386.deb
freeradius-mysql_1.1.7-1build4_i386.deb
freeradius-postgresql_1.1.7-1build4_i386.deb

Move these to a production server if this is your development workstation. (In this setup you won't be needing the postgresql , ldap, krb5 , iodbc , dbg, dialupadmin binaries.)

 

Step 2- Installing the binary packages

dpkg -i  freeradius_1.1.7-1build4_i386.deb

dpkg -i freeradius-mysql_1.1.7-1build4_i386.deb

After running with the out of the box configuration validate against a local user.

E.g: run radius in debug mode:

freeradius -X

From another shell run this while the freeradius -X is running:

radtest abc 123 localhost 1812 testing123

Make sure the user abc with password 123 is set in the /etc/freeradius/users file.



Setp 3- Configuring the FR with MySQL

First the MySQL bits (creating the db & its admin user). Do the following from your shell.

mysqladmin -u root password 123456

mysql -u root -p

On the MySQL shell type the following:

CREATE DATABASE radius;

GRANT ALL ON radius.* TO radius@localhost IDENTIFIED BY "radpass";

exit;

Import the the FreeRadius schema. The sample schema resides at this location: /usr/share/doc/freeradius/examples/mysql.sql.gz.

Gunzip it there:

gunzip -d /usr/share/doc/freeradius/examples/mysql.sql.gz

Do the following:

mysql -u root -p radius < /usr/share/doc/freeradius/examples/mysql.sql

To have a look  at the db schema do the following:

mysql -u root -p

use database radius;

show tables;

quit;

Now edit your /etc/freeradius/sql.conf.

Reset the user/password/database parameters to reflect the changes (eg. radius/radpass/radius); to turn the NAS management from MySQL, search for the line

readclients = no

and change it to

readclients = yes

Edit the file /etc/freeradius/radius.conf and add a line saying 'sql' to the authorize{} section (which is towards the end of the file). Also add a line saying 'sql' to the accounting{} section to tell FreeRadius to store accounting records in SQL as well. Optionally add 'sql' to the session{} section if you want to do Simultaneous-Use detection. Optionally add 'sql' to the post-auth{} section if you want to log all authentication attempts to SQL.

Here is the authorize section:

  authorize {
          preprocess
          chap
          mschap
          suffix
          eap
          sql
          pap
} 

And the accounting section:

  accounting {
          detail
          sql
 }

To insert a test user in the database, go to the MySQL shell and run this:

mysql -u root -p

mysql> use database radius;

mysql> INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('sqltest', 'Password', 'testpwd');

mysql> select * from radcheck where UserName='sqltest';

mysql> exit

Fire up radius in debug mode:

freeradius -X

Go to another shell and run the test:

radtest sqltest testpwd localhost 1812 testing123

At this moment you should see a message containing something like ... Accept-Accept ... which is an indication that your user is getting authenticated just fine.

Congratulations! Your FreeRadius + MySQL setup is working.

 

4- Setting up web management with Daloradius

The latest stable release is version 0.9-7.

Get hold of the it from http://sourceforge.net/projects/daloradius.

tar -zxvf daloradius-0.9-7.tar.gz

cp daloradius-0.9-7/ /var/www -R

Download the following prerequisites packages:

apt-get install apache2

apt-get install php php-mysql php-pear php-gd php-pear-DB

Change permissions and ownership:

chown www-data:www-data /var/www/daloradius-0.9-7 -R

chmod 644 /var/www/daloradius-0.9-7/library/daloradius.conf

Daloradius needs to add a few more tables to the radius database we already created earlier.

mysql -u root -p radius < /var/www/daloradius-0.9-7/contrib/db/mysql-daloradius.sql

Now, simply adjust the MySQL database information in  the DaloRadius config file.

vi /var/www/daloradius-0.9-7/library/daloradius.conf

Fill in the database details, a few important parameters are listed below:

    ...........
       ......................
       CONFIG_DB_ENGINE = mysql
       CONFIG_DB_HOST = 127.0.0.1
       CONFIG_DB_USER = radius
       CONFIG_DB_PASS = radpass
       CONFIG_DB_NAME = radius
       .......................
     ............

Save the file and exit.

Set up the apache server.

Edit the /etc/apache2/apache2.conf file and append this to the end of the file (customize to your likings):

  Alias /myradius "/var/www/daloradius-0.9-7/"
   <Directory /var/www/daloradius-0.9-7/>
      Options None
      order deny,allow
      deny from all
      allow from 127.0.0.1 
      allow from <my management system's ip which has a web-browser>
 </Directory>

Save and exit.

Restart the httpd server:

/etc/init.d/apache2 restart

Fire up Firefox (or any other borowser) and go to the URL http://<localhost or the managemet system's ip>/myradius.

Log in with the administrator for management:

    username: administrator
    password: radius

Change this information first for the sake of security (info is located in the operator table).

Take Daloradius for a spin. You should have created an sqltest user earlier. You can also try adding new users and testing the connectivity from within the Daloradius frontend.

Congratulations you are done.

Developers of  FreeRadius, MySQL and Daloradius, do accept my humble appreciation for all your efforts. Open source community, you also rock, thanx.

(Note: I haven't mentioned anything regarding setting up eap/ttls in this article. For that, just follow the section of setting up certificates and eap.conf from the below mentioned HowtoForge link.)

 

References:

http://freeradius.org/

http://wiki.freeradius.org/SQL_HOWTO

http://sourceforge.net/projects/daloradius

http://www.howtoforge.com/wifi-authentication-accounting-with-freeradius-on-centos5

http://www.linuxinsight.com/building-debian-freeradius-package-with-eap-tls-ttls-peap-support.html


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by dl7und (registered user) on Fri, 2008-09-12 02:42.

Why did my first comment disappear? There I had listed most corrections, like missing packages, incorrect package names, invalid packages, config modifications etc.

I suppose this has never actually been done on Hardy? Too many things are wrong...

Submitted by admin (registered user) on Fri, 2008-09-12 08:26.
Submitted by dl7und (registered user) on Mon, 2008-09-15 01:23.

Yes, that's the one, sorry. Must have gotten to the wrong place when I wrote it the second time. However, the comment still applies. This tutorial here can't work, there are too many problems. So for simplicity, I paste the comment in here:

###

 I can't remember all my modifications, so good luck to everyone trying this, but some hints anyway:

- Packages

  - more need to be installed, specifically build-essential, fakeroot, mysql-client-5.0, mysql-server.These are not installed by default on Hardy server.

  - libmysqlclient-dev has no installation candidate.

  - Instead of "apt-get install php php-mysql php-pear php-gd php-pear-DB" it should be "apt-get install php5 php5-mysql php-pear php5-gd php5-db".

- MySQL

  - Instead of "use database radius" it should be "use radius".

- Freeradius

  - In /etc/freeradius/users, comment out the line  "DEFAULT        Auth-Type = System" and the following one if you do not plan to go mad.

- misc

  - When copying daloradius to /var/www, omit the trailing slash! It should be "cp -R daloradius-0.9-7 /var/www".

Submitted by proletarian (registered user) on Wed, 2008-10-08 15:39.

hi,

Not  php5-db. must be php-db. If php-db not install. Cant open opendb.php.

thanx

Submitted by dl7und (registered user) on Thu, 2008-09-11 01:09.

The Apache process is restarted with "/etc/init.d/apache2 restart" on Ubuntu.

And reading the final note, I now know that it wouldn't have been necessary to build from source, since the only additional things these instructions enable in the source setup are not even used in this howto. It would have been nice to mention this at the beginning...

 PS: While enabling EAP and TLS flags before compiling, you also need to enable openssl support in debian/rules, otherwise the compile process will fail.

 

Submitted by awan (registered user) on Thu, 2008-09-11 04:54.

Thanx. Fixed the httpd thing & also added the openssl related stuff.

But the text regarding the need to compile the package with openssl or not, was present at the begining of the article. I just highlighted it now for the negligents (ref: centos thing ;) 

Good luck

Submitted by diego (not registered) on Sun, 2008-09-14 09:09.

Hi,

I tried

dpkg-buildpackage -rfakeroot

but it says that it cannot perform it...As you say in the tutorial you may need some more apt-get but what??

Thanks

Submitted by awan (registered user) on Mon, 2008-09-15 04:23.

See if this does the trick for u

apt-get install build-essential -y

Submitted by awan (registered user) on Mon, 2008-09-15 04:12.

Hey diego,
This process was carried out on ubuntu 8.04 LTS version with minimal/base install.  From there on apt-getting was done. Dependencies shouldn't be a problem. just hit "yes" whatever/whenever dependencies are prompted. Trying to stick with the theme/manifesto of howtoforge.com,  this tutorial should work for even the dummies. 

Make sure u have the exact same setup environment. Deviations are possible but only if u know what ur doing. 

For further information on dpkg-buildpackage check out this link
http://ubuntuforums.org/showthread.php?t=686131    OR
or
man fakeroot


Let me know if u find out any errors.

Good luck

--

Submitted by diego (not registered) on Thu, 2008-09-18 18:28.

Hi,

sorry to bother again...I tried other ways to install...but Daloradius didn't see the radius server on...

Anyway...I stick to the same problem.

When I run the dpkg-buildpackage it says:

Unmet dependencies: libgdbm-dev/ Build dependencies/coonflicts unsatisfied: aborting.

What shall I do?

Thanks

Submitted by awan (registered user) on Fri, 2008-09-19 04:51.

Hey Diego,
At the risk of inviting the wrath of falko, I responding to ur query again, since it more appropriately belongs to the discussion forums.

Anyway couple things that I need to remind the users of this how-to is that try to replicate the exact environment of the articles. i.e. Ubuntu 8.04 LTS (Server Edition), freeradius 1.7 .

The package libgdbm-dev is already being apt-get in the first step. It should automatically resolve the dependencies. See if u could check if it is still installed on not. if not re apt-get this package.
Furthermore if ur still having issues building the packages check out the link in references section. 

One more thing the problems can be isolated by just skipping the package-building step & using the default freeradius packages from the server  (which is without ssl support).

Good luck.

Note: if ur still having issues drop me an email or better yet open up a thread in the forums sections.

Submitted by Anonymous (not registered) on Thu, 2008-10-23 18:42.

I also am getting an error like this:

 root@ldap3:/freeradius-1.1.7# dpkg-buildpackage
dpkg-buildpackage: set CPPFLAGS to default value:
dpkg-buildpackage: set CFLAGS to default value: -g -O2
dpkg-buildpackage: set CXXFLAGS to default value: -g -O2
dpkg-buildpackage: set FFLAGS to default value: -g -O2
dpkg-buildpackage: set LDFLAGS to default value: -Wl,-Bsymbolic-functions
dpkg-buildpackage: source package freeradius
dpkg-buildpackage: source version 1.1.7-1build4
dpkg-buildpackage: source changed by Chuck Short <zulcss@ubuntu.com>
dpkg-buildpackage: host architecture i386
dpkg-checkbuilddeps: warning: can't parse dependency libsnmp-dev libssl-dev
dpkg-checkbuilddeps: error: error occurred while parsing Build-Depends
dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: warning: (Use -d flag to override.)

only libsnmp-dev and libssl-dev are quite clearly installed. I purged and reinstalled them to be sure, and rebooted. tried with -d, but still fails with the same problem later. this openssl license crap is beginning to seriously frustrate me...

Submitted by awan (registered user) on Fri, 2008-10-24 06:29.

Yes, this openssl crap has been source of frustration for lot many others. 
Anyway may I inquire what distribution ur using cuz Im beginning to think that ppl dont realize the difference between ubuntu LTS server & ubuntu desktop thingy. 

Im assuming (a big assumption I know) that apart from support duration and all, the server distro is a bit conservate in nature. i.e. not bleeding edge, not using the latest packages, i.e one step back from the latest packages due to issues related to stability/security etc.. 

If this is not the issue then u might want to check the references section which has the link to the package building of freeradius. If there is any mistake do let me know, so that I can fix it over here.

And if ur a bit of a faint heart then I can alway email u the packages that I've built.

let me know. Cheers
--
Oz