Hi, We are configuring FreeRadius with Mikrotik router. All the expected things are working but the maximum data usage allowed for a user is showing some issues. mysql> select * from radusergroup; +-----------+-----------+----------+ | username | groupname | priority | +-----------+-----------+----------+ *| lukup | testing | 1 |* mysql> select * from radgroupcheck; +----+---------------------------+---------------------+----+--------------+ | id | groupname | attribute | op | value | +----+---------------------------+---------------------+----+--------------+ | 1 | daloRADIUS-Disabled-Users | Auth-Type | := | Reject | | 25 | testing | Mikrotik-Rate-Limit | := | 1024k/1024k | *| 26 | testing | Max-Data | := | 5368709120 |* But its not taking the Max-Data value as defined. Its taking maximum 4GB. Fri Jul 3 14:20:31 2015 : Info: [acct_unique] Hashing 'NAS-Port = 2162163720,NAS-Identifier = "MikroTik",NAS-IP-Address = 192.168.1.1,Acct-Session-Id = "80e00008",User-Name = "lukup"' Fri Jul 3 14:20:31 2015 : Info: [sql] expand: %{User-Name} -> lukup Fri Jul 3 14:20:31 2015 : Info: [sql] sql_set_user escaped user --> 'lukup' Fri Jul 3 14:20:31 2015 : Info: [sql] expand: %{Acct-Input-Gigawords} -> 0 Fri Jul 3 14:20:31 2015 : Info: [sql] expand: %{Acct-Input-Octets} -> 397958 Fri Jul 3 14:20:31 2015 : Info: [sql] expand: %{Acct-Output-Gigawords} -> 0 Fri Jul 3 14:20:31 2015 : Info: [sql] expand: %{Acct-Output-Octets} -> 10134336 Fri Jul 3 14:20:31 2015 : Info: [sql] expand: UPDATE radacct SET framedipaddress = '%{Framed-IP-Address}', acctsessiontime = '%{Acct-Session-Time}', acctinputoctets = '%{%{Acct-Input-Gigawords}:-0}' << 32 | '%{%{Acct-Input-Octets}:-0}', acctoutputoctets = '%{%{Acct-Output-Gigawords}:-0}' << 32 | '%{%{Acct-Output-Octets}:-0}' WHERE acctsessionid = '%{Acct-Session-Id}' AND username = '%{SQL-User-Name}' AND nasipaddress = '%{NAS-IP-Address}' -> UPDATE radacct SET framedipaddress = '192.168.1.178', acctsessiontime = '61', acctinputoctets = '0' << 32 | '397958', acctoutputoctets = '0' << 32 | '10134336' WHERE acctsessionid = '80e00008' AND username = 'lukup' AND n Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 0 Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Released sql socket id: 0 Fri Jul 3 14:20:31 2015 : Info: ++[sql] = ok Fri Jul 3 14:20:31 2015 : Info: ++update control { Fri Jul 3 14:20:31 2015 : Info: sql_xlat Fri Jul 3 14:20:31 2015 : Info: expand: %{User-Name} -> lukup Fri Jul 3 14:20:31 2015 : Info: sql_set_user escaped user --> 'lukup' Fri Jul 3 14:20:31 2015 : Info: expand: SELECT (SUM(acctinputoctets)+SUM(acctoutputoctets)) AS Total FROM radacct where radacct.username='%{User-Name}' -> SELECT (SUM(acctinputoctets)+SUM(acctoutputoctets)) AS Total FROM radacct where radacct.username='lukup' Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 4 Fri Jul 3 14:20:31 2015 : Info: sql_xlat finished Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Released sql socket id: 4 Fri Jul 3 14:20:31 2015 : Info: expand: %{sql:SELECT (SUM(acctinputoctets)+SUM(acctoutputoctets)) AS Total FROM radacct where radacct.username='%{User-Name}'} -> 79051669 Fri Jul 3 14:20:31 2015 : Info: sql_xlat Fri Jul 3 14:20:31 2015 : Info: expand: %{User-Name} -> lukup Fri Jul 3 14:20:31 2015 : Info: sql_set_user escaped user --> 'lukup' Fri Jul 3 14:20:31 2015 : Info: expand: SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='%{User-Name}' AND radgroupcheck.attribute='Max-Data' -> SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='lukup' AND radgroupcheck.attribute='Max-Data' Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 3 Fri Jul 3 14:20:31 2015 : Info: sql_xlat finished Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Released sql socket id: 3 Fri Jul 3 14:20:31 2015 : Info: expand: %{sql: SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='%{User-Name}' AND radgroupcheck.attribute='Max-Data'} -> 5368709120 Fri Jul 3 14:20:31 2015 : Info: sql_xlat Fri Jul 3 14:20:31 2015 : Info: expand: %{User-Name} -> lukup Fri Jul 3 14:20:31 2015 : Info: sql_set_user escaped user --> 'lukup' Fri Jul 3 14:20:31 2015 : Info: expand: SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='%{User-Name}' AND radgroupcheck.attribute='Mikrotik-Rate-Limit' -> SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='lukup' AND radgroupcheck.attribute='Mikrotik-Rate-Limit' Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 2 Fri Jul 3 14:20:31 2015 : Info: sql_xlat finished Fri Jul 3 14:20:31 2015 : Debug: rlm_sql (sql): Released sql socket id: 2 Fri Jul 3 14:20:31 2015 : Info: expand: %{sql: SELECT radgroupcheck.value FROM radusergroup INNER JOIN radgroupcheck ON radusergroup.groupname = radgroupcheck.groupname WHERE radusergroup.username='%{User-Name}' AND radgroupcheck.attribute='Mikrotik-Rate-Limit'} -> 1024k/1024k Fri Jul 3 14:20:31 2015 : Info: ++} # update control = noop Fri Jul 3 14:20:31 2015 : Info: ++? if ("%{control:Tmp-Integer-0}" > "%{control:Tmp-Integer-1}") Fri Jul 3 14:20:31 2015 : Info: expand: %{control:Tmp-Integer-0} -> 79051669 Fri Jul 3 14:20:31 2015 : Info: *expand: %{control:Tmp-Integer-1} -> 4294967295* Fri Jul 3 14:20:31 2015 : Info: ? Evaluating ("%{control:Tmp-Integer-0}" > "%{control:Tmp-Integer-1}") -> FALSE Fri Jul 3 14:20:31 2015 : Info: ++? if ("%{control:Tmp-Integer-0}" > "%{control:Tmp-Integer-1}") -> FALSE We have to limit the max data limit for the user as 30. How we can do it? We have to use gigawords? can anyone advice on how this can be done. -- Randeep Mob: +919447831699[kerala] Mob: +919880050349[B'lore] http://twitter.com/Randeeppr http://in.linkedin.com/in/randeeppr [image: --] Randeep Raman [image: http://]about.me/Randeeppr <http://about.me/Randeeppr>
On Fri, Jul 03, 2015 at 03:27:08PM +0530, Randeep wrote:
mysql> select * from radgroupcheck; +----+---------------------------+---------------------+----+--------------+ | id | groupname | attribute | op | value | +----+---------------------------+---------------------+----+--------------+ | 1 | daloRADIUS-Disabled-Users | Auth-Type | := | Reject | | 25 | testing | Mikrotik-Rate-Limit | := | 1024k/1024k |
*| 26 | testing | Max-Data | := | 5368709120 |*
But its not taking the Max-Data value as defined. Its taking maximum 4GB.
Where did Max-Data come from? That's not in the mikrotik dictionary. You can't just make up attributes and expect the NAS to understand what you mean. I'm not familiar with Mikrotik, but looking in dictionary.mikrotik, Mikrotik-Total-Limit or Mikrotik-Total-Limit-Gigawords look more likely to be what you need to use. Refer to your NAS documentation to find the right attribute to use. Matthew -- Matthew Newton, Ph.D. <mcn4@le.ac.uk> Systems Specialist, Infrastructure Services, I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom For IT help contact helpdesk extn. 2253, <ithelp@le.ac.uk>
Hi Newton, We are using this parameter only for a "if" condition check. We are not sending this value to Mikrotik. If the SUM(acctinputoctets)+SUM(acctoutputoctets) > Max-Data, we are sending the Mikrotik-Rate-Limit to the Mikrotik to reduce the speed. But the issue is We are not able to set more than 4G to Max-Data. We will check Mikrotik-Total-Limit or Mikrotik-Total-Limit-Gigawords. But if anyone has any links for implementing the same please share with us. Regards, Randeep On Fri, Jul 3, 2015 at 3:59 PM, Matthew Newton <mcn4@leicester.ac.uk> wrote:
On Fri, Jul 03, 2015 at 03:27:08PM +0530, Randeep wrote:
mysql> select * from radgroupcheck;
+----+---------------------------+---------------------+----+--------------+
| id | groupname | attribute | op | value |
+----+---------------------------+---------------------+----+--------------+
| 1 | daloRADIUS-Disabled-Users | Auth-Type | := | Reject | | 25 | testing | Mikrotik-Rate-Limit | := | 1024k/1024k |
*| 26 | testing | Max-Data | := | 5368709120 |*
But its not taking the Max-Data value as defined. Its taking maximum 4GB.
Where did Max-Data come from? That's not in the mikrotik dictionary. You can't just make up attributes and expect the NAS to understand what you mean.
I'm not familiar with Mikrotik, but looking in dictionary.mikrotik, Mikrotik-Total-Limit or Mikrotik-Total-Limit-Gigawords look more likely to be what you need to use.
Refer to your NAS documentation to find the right attribute to use.
Matthew
-- Matthew Newton, Ph.D. <mcn4@le.ac.uk>
Systems Specialist, Infrastructure Services, I.T. Services, University of Leicester, Leicester LE1 7RH, United Kingdom
For IT help contact helpdesk extn. 2253, <ithelp@le.ac.uk> - List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Randeep Mob: +919447831699[kerala] Mob: +919880050349[B'lore] http://twitter.com/Randeeppr http://in.linkedin.com/in/randeeppr [image: --] Randeep Raman [image: http://]about.me/Randeeppr <http://about.me/Randeeppr>
On 03-07-15 12:59, Randeep wrote:
Hi Newton,
We are using this parameter only for a "if" condition check. We are not sending this value to Mikrotik.
If the SUM(acctinputoctets)+SUM(acctoutputoctets) > Max-Data, we are sending the Mikrotik-Rate-Limit to the Mikrotik to reduce the speed.
But the issue is We are not able to set more than 4G to Max-Data.
Is Max-Data defined as an integer? If so, it is a 32bit unsigned integer, and 4G is the maximum value that fits in there. Change it to a integer64, or perform some magic with splitting it into two values with bitshifting operations. The first option is probably the easiest. -- Herwin Weststrate
Hi Herwin, mysql> select * from radgroupcheck; +----+---------------------------+---------------------+----+--------------+ | id | groupname | attribute | op | value | +----+---------------------------+---------------------+----+--------------+ | 1 | daloRADIUS-Disabled-Users | Auth-Type | := | Reject | | 25 | testing | Mikrotik-Rate-Limit | := | 1024k/1024k | | 26 | testing | Max-Data | := | 5368709120 | | 22 | admins | Mikrotik-Rate-Limit | := | 256k/256k | | 16 | power | Max-Data | := | 107374182400 | *| 15 | premium | Max-Data | := | 53687091200 |* | 14 | starter | Max-Data | := | 32212254720 | | 13 | admins | Max-Data | := | 1073741824 | +----+---------------------------+---------------------+----+--------------+ 8 rows in set (0.00 sec) mysql> desc radgroupcheck; +-----------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+------------------+------+-----+---------+----------------+ | id | int(11) unsigned | NO | PRI | NULL | auto_increment | | groupname | varchar(64) | NO | MUL | | | | attribute | varchar(64) | NO | | | | | op | char(2) | NO | | == | | *| value | varchar(253) | NO | | | |* +-----------+------------------+------+-----+---------+----------------+ 5 rows in set (0.00 sec) I dont know where i have to convert into 64 bit integer. It looks like the datatype is varchar. Regards, Randeep On Fri, Jul 3, 2015 at 5:39 PM, Herwin Weststrate <herwin@quarantainenet.nl> wrote:
On 03-07-15 12:59, Randeep wrote:
Hi Newton,
We are using this parameter only for a "if" condition check. We are not sending this value to Mikrotik.
If the SUM(acctinputoctets)+SUM(acctoutputoctets) > Max-Data, we are sending the Mikrotik-Rate-Limit to the Mikrotik to reduce the speed.
But the issue is We are not able to set more than 4G to Max-Data.
Is Max-Data defined as an integer? If so, it is a 32bit unsigned integer, and 4G is the maximum value that fits in there. Change it to a integer64, or perform some magic with splitting it into two values with bitshifting operations. The first option is probably the easiest.
-- Herwin Weststrate
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
-- Randeep Mob: +919447831699[kerala] Mob: +919880050349[B'lore] http://twitter.com/Randeeppr http://in.linkedin.com/in/randeeppr [image: --] Randeep Raman [image: http://]about.me/Randeeppr <http://about.me/Randeeppr>
put in dictionary.mikrotik and define as integer64 Pada 3 Jul 2015 20.58, "Herwin Weststrate" <herwin@quarantainenet.nl> menulis:
On 03-07-15 15:31, Randeep wrote:
Hi Herwin,
I dont know where i have to convert into 64 bit integer. It looks like the datatype is varchar.
The datatype of the RADIUS attribute, in the dictionary, not in the database.
-- Herwin Weststrate
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
participants (4)
-
Herwin Weststrate -
johan firdianto -
Matthew Newton -
Randeep