Hi,
Not sure if this is the right forum for this, but it seems most similar questions have been asked here.
I’m new to Mikrotik & RADIUS, and have successfully set up a Mikrotik based AP, that acts as a radius client to a freeRADIUS server.
I would like to be able to “bill” Hotspot users according to the amount of traffic they use, instead of setting time limits.
I wish to have customers to pay upfront, i.e. they buy a set amount of MBs before connecting.
Where do I start? Is there a way to do this with Mikrotik without scripting? Is this more of a freeRADIUS issue?
Can anyone please help?
Regards,
Henk
ICQ: 2004804
Everything is possible, but the ‘no scripting’ part of your question limits things a bit.
I have the following in my freeradius sql.conf:
accounting_stop_query = "UPDATE radacct, userinfo SET ${acct_table1}.AcctStopTime = '%S', ${acct_table1}.AcctSessionTime = '%{Acct-Session-Time}', ${acct_table1}.AcctInputOctets = '%{Acct-Input-Octets}', ${acct_table1}.AcctOutputOctets = '%{Acct-Output-Octets}', ${acct_table1}.AcctTerminateCause = '%{Acct-Terminate-Cause}', ${acct_table1}.AcctStopDelay = '%{Acct-Delay-Time}', ${acct_table1}.ConnectInfo_stop = '%{connect-Info}', ${userinfo_table1}.PrePaid = ${userinfo_table1}.PrePaid - %{Acct-Output-Octets} WHERE ${acct_table1}.AcctSessionId = '%{Acct-Session-Id}' AND ${acct_table1}.UserName = '%{SQL-User-Name}' AND ${userinfo_table1}.UserName = '%{SQL-User-Name}' AND NASIPAddress = '%{NAS-IP-Address}'"
Basically I have created a ‘PrePaid’ column in the userinfo table that keeps the User’s data. When they make purchases, data is added to this value. Everytime they log off, the amount used during that session is subtracted by freeradius using the above statement. The item of interest is as follows:
${userinfo_table1}.PrePaid = ${userinfo_table1}.PrePaid - %{Acct-Output-Octets}
Just before they log in I assign the PrePaid value to the Xmit-Limit in the radreply table to make sure they don’t exceed their amount.
Hope this helps.