FreeRadius2 + MySQL + Data Cap
-
Hi all
I am trying to setup a hotspot where all users get a free daily download quota (50mb).
I am going to use the cp to add the users MAC to mysql via php and authenticate from there, however i am able to get the quota working!
The quota works when not using mysql so there must be something i need to do in mysql.
Any ideas?
Lloyd
-
can anyone even give me a hint? PLEAAASSSSE
-
I guess we need some more information about your setup and config.
What is your current quota setup?
-
you need to do accounting on mysql. Never used this myself but this could help you on starting work:
http://wiki.freeradius.org/modules/Rlm_sqlcounter
http://lists.freeradius.org/pipermail/freeradius-users/2012-February/058923.html -
I finally got this sorted, and to help anyone else out here is what worked for me (i am writing this from home mostly from memory, but you will get the idea), most of what i have done is based on this link http://forum.pfsense.org/index.php/topic,57260.msg305604.html#msg305604
-
Get the basic captive portal and freeradius setup and make sure it works with local users.
-
Install php-mysql support as detailed at the above link
-
Edit the file /usr/local/etc/raddb/sql/mysql/counter.conf and replace with the contents of the one attached to this post.
-
Edit /usr/local/pkg/freeradius.inc and add the counters from the counter.conf (DailyDataCounter, MonthlyDataCounter & NoResetCounter) to the "Instantiation" section of raddb.conf and sites-enabled default.conf. I removed the references to the other time based counters i.e. daily, weekly & monthly. This file needs to be modified otherwise any changes to the raddb.conf file will reset on a reboot
-
Modify the default captive portal and error page with the one attached to this post and add the other attachents through captive file manager.
-
Enable sql otherwise it will not be used
-
Run the sql in the attached "SQL-Groups.txt" to create groups to assign amount of traffic.
-
make sure the captive portal is set to auto authenticate every minute.
In theory any one who connects through the captive portal will be asked to register, and they will by default have 30mb of daily download.
This may not be the best way but and if anyone wants to correct me go for it as i just want to learn.
(captiveportal-cp.css).txt
(captiveportal-error.htm).txt
(captiveportal-initial.php).txt
(captiveportal-register.php).txt
(counter.conf).txt
(SQL-Setup.sql).txt -