Syed Jahanzaib Personal Blog to Share Knowledge !

September 29, 2011

Howto Create HTTP File Sharing Server with Freeradius Backend + [Daloradius Frontend Optional]

Filed under: Linux Related, Mikrotik Related — Tags: , , , , , — Syed Jahanzaib / Pinochio~:) @ 2:06 PM


Following is a complete guide on howto setup Apache to use FreeRadius authentication module along with DALORADIUS as a front-end. You can also use this guide to create full featured RADIUS server for your MIKROTIK or any other NAS which have external RADIUS authentication support in it.
Also this guide will illustrate you howto configure DALORADIUS. which is an advanced RADIUS web management application aimed at managing hotspots and general-purpose ISP deployments. It features user management, graphical reporting, accounting, a billing engine. It  is basically an nice GUI Frontend to control FREERADIUS. Using DR, you can create single/batch users, hotspot tickets, create plans n packages etc etc.

In the end I will show you howto create a APACHE base file sharing server which will use FREERADIUS for authentication🙂

Few months back , @ my friend’s , I installed  Mikrotik along with DMASOFTLAB RADIUS MANAGER which also uses FREERADIUS as backend authentication mechanism. They also had a 4 TB of windows IIS base FTP sharing server for Videos, Mp3, Games and etc for LAN users. All network was running on private ips, so setting authentication on sharing server so only valid users can access FTP was a headache, so for the time being I placed FTP server behind Mikrotik DMZ so that only pppoe dialer connected users can access them, BUT this topology had a negative impact on overall Mikrotik performance because huge amount of (JUNK FTP) irrelevant traffic was going through the router which was increasing overall load on MT, so I decided to overcome this problem by changing the sharing server operating system from Microsoft Windows to UBUNTU Linux, and then I placed  it on users subnet and then link this sharing server [apache] authentication with freeradius. This way I managed to solve the problem. This guide will show you how I exactly did this.

Here we go . . .

We will divide this article in two categories.


2) How to authenticate Apache 2 with Radius

[Please note that I am using UBUNTU 10.4 and ip address is, all packages are installed in this single box for testing purpose,  you can separate them as per your requirements]

1) Installing FREERADIUS Server along with MYSQL+DALORADIUS :

I prefer installing the whole pre-requisite LAMP package (lamp-server stands for Linux-Apache-MySQL-PHP server). First We install lamp-server using the command below:

sudo tasksel install lamp-server

(you will need to enter root password, which is “123”  in my case , to continue the installation)

Now Install freeradius package

sudo apt-get install freeradius

Install freeradius ldap authentication

sudo apt-get install freeradius-ldap

Install freeradius to run with mysql

sudo apt-get install freeradius-mysql

After finishing the above installations, restart the FreeRADIUS service

sudo /etc/init.d/freeradius restart

If you are using Ubuntu, remove /commend the IPV6 entry from /etc/hosts

nano /etc/hosts
# The following lines are desirable for IPv6 capable hosts
# ::1     localhost ip6-localhost ip6-loopback

Now, you can test the Radius Server using radtest package, the command will be as below:

radtest radius 123 localhost 1812 123
(you will see its result something like below)
Sending Access-Request of id 198 to port 1812
User-Name = "radius"  User-Password = "123" NAS-IP-Address =
NAS-Port = 1812 rad_recv: Access-Accept packet from host port 1812, id=198, length=20
Which shows your RADIUS Server is in working condition. 

Now Download DALORADIUS which is hosted on sourceforge at the address of and you may get the latest release from there ( I used 0.9.9) or use the wget command to download in any temp folder e.g /temp

mkdir /temp
cd /temp
tar -zxvf daloradius-0.9-9.tar.gz
mv daloradius-0.9-9.tar.gz daloradius
cp daloradius/ /var/www -R
chown www-data:www-data /var/www/daloradius -R chmod 644 /var/www/daloradius/library/daloradius.conf.php

MYSQL Database Setup

Now, we create the database for FreeRADIUS and an user account which will be used by FreeRADIUS to access into database. then import both freeradius and daloradius tables using this schema:
We will run the following command to Login MySQL Database

mysql -u root -p123
grant all privileges on radius.* to 'radius'@'localhost';

Now Import Daloradius mysql tables . . .

cd /var/www/daloradius/contrib/db/
mysql -u root -p radius < fr2-mysql-daloradius-and-freeradius.sql
mysql -u root -p radius < mysql-daloradius.sql

Database Connection SetupNow, simply adjust the MySQL database information in daloRADIUS’s config file.

cd /var/www/daloradius/library/
nano -w daloradius.conf.php
$configValues['FREERADIUS_VERSION'] = '2';
$configValues['CONFIG_DB_PASS'] = '123';
$configValues['CONFIG_DB_TBL_RADUSERGROUP'] = 'radusergroup';

Freeradius + mysql + daloradius Installation Complete.
Point your browser to

Login to the management:

username: administrator
password: radius

Here you can add users / plans etc etc. Please see daloraidus web site for more support info. Add some test users so that you test it later when apache ask authentication.
You can also test this user with radtest.

radtest testuser testpassword localhost 1812 123

How to authenticate Apache 2 with RADIUS.

First we will install Apache radius module :

apt-get install libapache2-mod-auth-radius
a2enmod auth_radius

Now open /etc/apache2/apache2.conf and add the following lines to end of file,

AddRadiusAuth localhost:1812 123 5:3
AddRadiusCookieValid 1

Now For example we have mounted our 1 TB sharing Harddisk in /mnt/test and we want that if user try to open in there browser , an Authentication Popup must appear to force user enter there valid radius user id password to further proceed, then Add the following lines in /etc/apache2/apache2.conf  in the end.

Alias /test /mnt/test
<Directory /mnt/test>
Options Indexes FollowSymlinks
AuthType Basic
AuthName "AA File Server Authentication"
AuthBasicAuthoritative Off
AuthBasicProvider radius
AuthRadiusAuthoritative on
AuthRadiusActive On
Require valid-user </Directory>

Now Point your browser to and you will see authentication popup window , something like below image.

If the user supply wrong id password, he will see

If user enters valid id password, he will see the content of test folder.

Allah Hafiz,



  1. AWESOME, dear sir daloradius manual copy please

    Comment by kureshi mn — April 9, 2012 @ 12:47 AM

    • I have no manual for DOLARADIUS. I just installed it for some test purposes, as a front-end for free-radius. I only followed few guides on the internet and it worked. You can ask its author or consult there website for the manual.

      Comment by Syed Jahanzaib / Pinochio~:) — April 9, 2012 @ 8:29 AM

  2. Salam Sir, Kindly tell me the minimum requirement for selfmade radius server(freeradius+mysql+daloradius) for small network(10-20 user). I want to implement it for learning purpose. One more thing I have a squid caching server 512mb ram + 36 gb scsi my cache size is 9 gb. can i this radius server on same machine(squid cache).

    Comment by backupsite — April 14, 2012 @ 12:15 AM

    • If its for learning purpose only, you can use the same box for SQUID and RADIUS. Even it will work fine on small number of users.

      However not recommended to use it on a production environment. In general, Proxy server are Memory hunger beast, and they requires fairly large amount of Memory, Fast HDD, and fast CPU to get good performance.

      Comment by Syed Jahanzaib / Pinochio~:) — April 14, 2012 @ 7:58 PM

      • Salam sir.
        Can you please send me the step by step configuration of radius server n daloradius for mikrotik server. I want to apply billing server for hotspot but i dont know how to integrated daloradius server with mikrotik for authentication n billing. Please send
        Me the step by step configuration.

        Please send in my email address

        Comment by Aliakbar — April 18, 2012 @ 10:08 PM

      • I don’t have its step by step guide. However Basic ver to show installation and user creation is already showed in this article.
        Please refer to dolaradius web site for its guide. Complete guide is available on Charges basis at its author website. Search the Google and you will find some guides , hopefully.

        Comment by Syed Jahanzaib / Pinochio~:) — April 19, 2012 @ 8:43 AM

  3. thank you.

    Comment by backupsite — April 19, 2012 @ 4:55 PM

  4. Hi Zaib nice post you’ve got i was thinking if one could do a time based login with daloradius, is it possible? Thank you.

    Comment by woronti — May 28, 2012 @ 9:42 PM

    • Dear sir
      i have daloradius server centos os and but it not working on dashboard my developer not support me can u support please suggest me thanks allahhafiz mail id deccannet [at]

      Comment by kureshi mn — May 30, 2012 @ 9:12 AM

      • Sorry, I haven’t worked on DOLARADIUS in deep, I once configure it for some sharing purposes. Search the forum and google.

        Comment by Syed Jahanzaib / Pinochio~:) — June 4, 2012 @ 10:04 AM

  5. The method is very simple i believed…… But sorry no success i tried almost 10 times using ubuntu server 10.4 n even i keep the password same as in ur case. in my case freeradius restart ok ok n after im stuck here:

    radtest radius 123 localhost 1812 123
    Sending Access-Request of id 125 to port 1812
    User-Name = “radius”
    User-password = “123”
    NAS-IP-Address =
    NAS-Port = 1812
    rad_recv: Access-Reject packet from host port 1812, id=125, length-20
    rad_verify: Received Access-Reject packet from client port 1812 with invalid signature (err=2)! (Shared secret is incorrect.)

    Comment by Shahan Ali — October 17, 2012 @ 1:31 AM

    • I have not worked on free radius since long. I will check it in LAB in free timings and will let you know.

      In the meanwhile, the error you posted is quite self explanatory. check your secret for typo mistakes in config.

      Comment by Syed Jahanzaib / Pinochio~:) — October 17, 2012 @ 8:42 AM

  6. what did you have to configure in freeradius that freeradius could connect to the mysql-db?
    or did you just importet the dolaradius shema?

    Comment by N.L — March 14, 2013 @ 10:43 PM

  7. i want to start radius server with daloradius can u help me i trying but its not working pls give me you contact number or online chat please help me

    Comment by shaikh riyaz — December 9, 2013 @ 12:30 AM

  8. how to connect daloradius with mikrotik

    Comment by riyaz — December 14, 2013 @ 12:19 AM

  9. pls help me, i want to create a plan and profile so that the users will be limited to 1pm to 4pm daily
    thank you

    Comment by mike — September 19, 2014 @ 11:01 AM

    • do you have any billing system lik user man / radius ?
      what authentication you are using for clients? hotspot ? pppoe? or what? define your network.

      Comment by Syed Jahanzaib / Pinochio~:) — September 22, 2014 @ 3:43 PM

  10. dear janzaib
    i just want to do daloraduis+free radius+mysql for user authentication with mikrotik pppoe server but i want to do this with my squid server machine, i dont want apache server bcoz its only squid server without GUI and machine has 16gb of ram xeon dual core 2 processors 3.6ghz and 15k rpm harddive, just want to add radius AAA server with it
    i have 250 users and 80 users alway connected.
    30 to 40 users always using services.
    my 24 hours network usage is 150 giga bytes. ( not bits )
    what u suggest ? should i deploy it with squid or i have buy another one only for radius
    my microsoft sharing server has 10TB data and daily usage of sharing server is 500GB (not bits) i m sure u dont tell me to deploy radius with my sharing server.
    waiting 4 ur reply with clear explaination🙂
    thanking you

    Comment by Rehmat ali — October 2, 2014 @ 3:54 PM

    • You can do it in Squid box if the resources are enough, also by seeing the size of your network, It will work just fine, it wont take much load.
      but i suggest if you want some more advance functions, then go with radius manager, its good for mini isps networks with lots of functions, enhancements and other features.

      Comment by Syed Jahanzaib / Pinochio~:) — October 3, 2014 @ 9:18 AM

  11. root@ubuntu:/temp# chown www-data:www-data /var/www/daloradius -R chmod 644 /var/www/daloradius/library/daloradius.conf.php
    chown: cannot access `chmod’: No such file or directory
    chown: cannot access `644′: No such file or directory

    Comment by ramanji — December 14, 2014 @ 6:25 PM

  12. Hi all
    i have it working but i can’t configure it to logout may someone please help

    Comment by Nkosikhona — November 13, 2015 @ 6:23 PM

  13. sir how to get those username or password who have entered wrong username and password in radius

    Comment by zubair — July 12, 2016 @ 7:07 PM

  14. are this applicable up to this day where the version of free radius is 3.0.11?? if i’m not mistaken and im using also ubuntu 16.04 and my router is d-link? or this applicable with any routers?
    pls help thanks

    Comment by christopher — August 31, 2016 @ 5:56 PM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at

%d bloggers like this: