Is there way to convert output octets and input octets to KB
Hi there As I say from title is there any way to convert output and input octets to KB because I have small problem when I add to mysql value with 12 number in radtest I get small error it's give me the result just 10 number and note what I insert in SQL , I insert I SQL 10737418240 to limit my users 10 GB for total octets but in radtest I get other result but if I add 10 8 number I get same number in result any help for this ?
On Jun 15, 2019, at 4:49 PM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
As I say from title is there any way to convert output and input octets to KB because I have small problem when I add to mysql value with 12 number in radtest I get small error it's give me the result just 10 number and note what I insert in SQL , I insert I SQL 10737418240 to limit my users 10 GB for total octets but in radtest I get other result but if I add 10 8 number I get same number in result any help for this ?
That's a rather confused question. From what I can tell, there are a few issues. One is that you can't use Acct-Input-Octets or Acct-Output-Octets to hold more than 4G of data. Those attributes are defined to be 32 bits. For larger counters, see Acct-Input-Gigawords. Which is defined to be the number of times Acct-Input-Octets has rolled over 4G. The default SQL schema allows FreeRADIUS to store more than 4G of counters in the DB. The default SQL queries use both Acct-Input-Octets and Acct-Input-Gigawords to calculate the correct 64-bit values to store in SQL. So that should work. It also looks like you're trying to *limit* user downloads via some attribute. You say:
I insert I SQL 10737418240 to limit my users 10 GB for total octets
Which is vague to the point of uselessness. WHERE in SQL do you insert these values? If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use. Alan DeKok.
Exactly, the first part of your reply is what happen in my case if I need to use 64 bits how can I do that in freeradius ? في الأحد، ١٦ يونيو، ٢٠١٩ ٢:١٧ م Alan DeKok <aland@deployingradius.com> كتب:
On Jun 15, 2019, at 4:49 PM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
As I say from title is there any way to convert output and input octets to KB because I have small problem when I add to mysql value with 12 number in radtest I get small error it's give me the result just 10 number and note what I insert in SQL , I insert I SQL 10737418240 to limit my users 10 GB for total octets but in radtest I get other result but if I add 10 8 number I get same number in result any help for this ?
That's a rather confused question. From what I can tell, there are a few issues.
One is that you can't use Acct-Input-Octets or Acct-Output-Octets to hold more than 4G of data. Those attributes are defined to be 32 bits. For larger counters, see Acct-Input-Gigawords. Which is defined to be the number of times Acct-Input-Octets has rolled over 4G.
The default SQL schema allows FreeRADIUS to store more than 4G of counters in the DB. The default SQL queries use both Acct-Input-Octets and Acct-Input-Gigawords to calculate the correct 64-bit values to store in SQL.
So that should work.
It also looks like you're trying to *limit* user downloads via some attribute. You say:
I insert I SQL 10737418240 to limit my users 10 GB for total octets
Which is vague to the point of uselessness. WHERE in SQL do you insert these values?
If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Jun 16, 2019, at 7:29 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
Exactly, the first part of your reply is what happen in my case if I need to use 64 bits how can I do that in freeradius ?
Use 64 bits WHERE? And if you read my answer, you'll see that this isn't a problem. FreeRADIUS already does the right thing. So which version are you using? Are you using the default schema / queries? What is going wrong? You need to write better descriptions of what you're trying to do. We can't read your mind. We don't know what you're doing. We don't know what you're thinking. Explain yourself. Learn how to ask good questions. It's the only way to get a problem fixed. Or, continue to send content-free vague messages to the list, at which point they will be ignored. Alan DeKok.
ok , i need to limit total octets for users so i add sqlcounter : sqlcounter total_limit{ counter_name = 'Max-Total-Bandwidth' check_name = 'Total-Bandwidth' sql_module_instance = sql key = 'User-Name' dialect = mysql reset = never query = "SELECT SUM(acctinputoctets) + SUM(acctoutputoctets) FROM radacct WHERE UserName='%{${key}}'" } its work fine for 4 GB but if i need to limit it to 10 GB or more the server give another value not what i add some examble : insert into radcheck (username,attribute,op,value) values ("sw392"," Cleartext-Password",":=","sw"); insert into radcheck (username,attribute,op,value) values ("sw392"," Monthly-Bandwidth ",":="," 10737418240"); when i do radtest sw392 sw 127.0.0.1 10 XXXXX i get User-Name = "sw392" User-Password = "sw" NAS-IP-Address = 127.0.0.1 NAS-Port = 10 Message-Authenticator = 0x00 Cleartext-Password = "sw" Received Access-Accept Id 61 from 127.0.0.1:1812 to 0.0.0.0:0 length 26 Session-Timeout = 2147483648 the session-timeout is my Monthly-Bandwidth attribute as you see i get different value from what i insert in sql my freeradius V radiusd: FreeRADIUS Version 3.0.13, for host x86_64-redhat-linux-gnu, built on May 13 2019 at 19:48:02 FreeRADIUS Version 3.0.13 Copyright (C) 1999-2017 The FreeRADIUS server project and contributors * i use default /etc/raddb/mods-config/sql/main/mysql/ ( schema / queries ) sorry for my bad language . On Sun, Jun 16, 2019 at 2:33 PM Alan DeKok <aland@deployingradius.com> wrote:
On Jun 16, 2019, at 7:29 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
Exactly, the first part of your reply is what happen in my case if I need to use 64 bits how can I do that in freeradius ?
Use 64 bits WHERE?
And if you read my answer, you'll see that this isn't a problem. FreeRADIUS already does the right thing.
So which version are you using? Are you using the default schema / queries? What is going wrong?
You need to write better descriptions of what you're trying to do. We can't read your mind. We don't know what you're doing. We don't know what you're thinking.
Explain yourself. Learn how to ask good questions. It's the only way to get a problem fixed.
Or, continue to send content-free vague messages to the list, at which point they will be ignored.
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Jun 16, 2019, at 7:56 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
ok , i need to limit total octets for users so i add sqlcounter :
sqlcounter total_limit{ counter_name = 'Max-Total-Bandwidth' check_name = 'Total-Bandwidth' sql_module_instance = sql key = 'User-Name' dialect = mysql reset = never query = "SELECT SUM(acctinputoctets) + SUM(acctoutputoctets) FROM radacct WHERE UserName='%{${key}}'" }
its work fine for 4 GB but if i need to limit it to 10 GB or more the server give another value not what i add some examble :
You shouldn't need to do that. The sqlcounter module has supported 64-bit counters since 3.0.4, in 2014.
insert into radcheck (username,attribute,op,value) values ("sw392"," Cleartext-Password",":=","sw"); insert into radcheck (username,attribute,op,value) values ("sw392"," Monthly-Bandwidth ",":="," 10737418240");
when i do radtest sw392 sw 127.0.0.1 10 XXXXX
i get
User-Name = "sw392" User-Password = "sw" NAS-IP-Address = 127.0.0.1 NAS-Port = 10 Message-Authenticator = 0x00 Cleartext-Password = "sw" Received Access-Accept Id 61 from 127.0.0.1:1812 to 0.0.0.0:0 length 26 Session-Timeout = 2147483648
the session-timeout is my Monthly-Bandwidth attribute as you see i get different value from what i insert in sql
Yes, because Session-Timeout is a 32-bit integer. If you're doing to put values larger than 4G into a 32-bit integer, it won't work. If you're going to limit bandwidth by putting bandwidth values into Session-Timeout, it won't work. The sqlcounter module supports 64-bit values just fine. One issue, though is that the module is made to count *time* not *bandwidth*. All of the documentation and examples show it counting time. And when you test it, you see the module setting Session-Timeout. *Not* any bandwidth limitation. So again, what are you trying to do? You've posted a configuration here, but you're not really describing the problem. Are you trying to limit bandwidth that the users can download? Did you *READ* my previous response which explained the problem with that? Alan DeKok.
yes , i tray to limit bandwidth download and upload so if users get all limit they get access reject what is best way to limit it . thank u your replay very helpful all things now clear , but from your first replay u say " If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use. " i need to limit total bandwidth octets not (rx/tx) limit Note : i use my openwrt as nas ( wpa-enterprise ) On Sun, Jun 16, 2019 at 4:03 PM Alan DeKok <aland@deployingradius.com> wrote:
On Jun 16, 2019, at 7:56 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
ok , i need to limit total octets for users so i add sqlcounter :
sqlcounter total_limit{ counter_name = 'Max-Total-Bandwidth' check_name = 'Total-Bandwidth' sql_module_instance = sql key = 'User-Name' dialect = mysql reset = never query = "SELECT SUM(acctinputoctets) + SUM(acctoutputoctets) FROM
radacct
WHERE UserName='%{${key}}'" }
its work fine for 4 GB but if i need to limit it to 10 GB or more the server give another value not what i add some examble :
You shouldn't need to do that. The sqlcounter module has supported 64-bit counters since 3.0.4, in 2014.
insert into radcheck (username,attribute,op,value) values ("sw392"," Cleartext-Password",":=","sw"); insert into radcheck (username,attribute,op,value) values ("sw392"," Monthly-Bandwidth ",":="," 10737418240");
when i do radtest sw392 sw 127.0.0.1 10 XXXXX
i get
User-Name = "sw392" User-Password = "sw" NAS-IP-Address = 127.0.0.1 NAS-Port = 10 Message-Authenticator = 0x00 Cleartext-Password = "sw" Received Access-Accept Id 61 from 127.0.0.1:1812 to 0.0.0.0:0 length 26 Session-Timeout = 2147483648
the session-timeout is my Monthly-Bandwidth attribute as you see i get different value from what i insert in sql
Yes, because Session-Timeout is a 32-bit integer.
If you're doing to put values larger than 4G into a 32-bit integer, it won't work.
If you're going to limit bandwidth by putting bandwidth values into Session-Timeout, it won't work.
The sqlcounter module supports 64-bit values just fine. One issue, though is that the module is made to count *time* not *bandwidth*. All of the documentation and examples show it counting time. And when you test it, you see the module setting Session-Timeout. *Not* any bandwidth limitation.
So again, what are you trying to do? You've posted a configuration here, but you're not really describing the problem.
Are you trying to limit bandwidth that the users can download? Did you *READ* my previous response which explained the problem with that?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Jun 16, 2019, at 9:27 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
yes , i tray to limit bandwidth download and upload so if users get all limit they get access reject what is best way to limit it . thank u your replay very helpful all things now clear ,
Again, does your NAS support this feature? I've asked that question many times, and you've ignored it.
but from your first replay u say
" If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use. "
i need to limit total bandwidth octets not (rx/tx) limit
Note : i use my openwrt as nas ( wpa-enterprise )
That's nice. Do you want *me* to read the OpenWRT documentation and explain it to you? Or are you going to read it yourself? Alan DeKok.
Yes my nas (openwrt) support it , no problem with it . في الأحد، ١٦ يونيو، ٢٠١٩ ٦:٢٢ م Alan DeKok <aland@deployingradius.com> كتب:
On Jun 16, 2019, at 9:27 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
yes , i tray to limit bandwidth download and upload so if users get all limit they get access reject what is best way to limit it . thank u your replay very helpful all things now clear ,
Again, does your NAS support this feature? I've asked that question many times, and you've ignored it.
but from your first replay u say
" If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use. "
i need to limit total bandwidth octets not (rx/tx) limit
Note : i use my openwrt as nas ( wpa-enterprise )
That's nice. Do you want *me* to read the OpenWRT documentation and explain it to you? Or are you going to read it yourself?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
Dear Alan What Is best way to limit bandwidth usage from freeradius if our NAS support , Thx في الأحد، ١٦ يونيو، ٢٠١٩ ٦:٢٩ م Mustafa Nassir <mustafa.n.gaid@gmail.com> كتب:
Yes my nas (openwrt) support it , no problem with it .
في الأحد، ١٦ يونيو، ٢٠١٩ ٦:٢٢ م Alan DeKok <aland@deployingradius.com> كتب:
On Jun 16, 2019, at 9:27 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
yes , i tray to limit bandwidth download and upload so if users get all limit they get access reject what is best way to limit it . thank u your replay very helpful all things now clear ,
Again, does your NAS support this feature? I've asked that question many times, and you've ignored it.
but from your first replay u say
" If you're trying to enforce download limits on users, this isn't part of standard RADIUS. You cannot put Acct-Input-Octets into an Access-Accept, and expect that the NAS will enforce that. You have to read the NAS documentation to see (1) if the NAS is capable of this, and (2) which vendor-specific attributes to use. "
i need to limit total bandwidth octets not (rx/tx) limit
Note : i use my openwrt as nas ( wpa-enterprise )
That's nice. Do you want *me* to read the OpenWRT documentation and explain it to you? Or are you going to read it yourself?
Alan DeKok.
- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html
On Jun 17, 2019, at 9:06 AM, Mustafa Nassir <mustafa.n.gaid@gmail.com> wrote:
What Is best way to limit bandwidth usage from freeradius if our NAS support ,
I've been trying to tell you. I'm not sure why it's unclear. a) find out what attributes the NAS needs to enforce bandwidth limitation b) configure sqlcounter to use them Hint: it's not "Session-Timeout", as you posted in an earlier message. Alan DeKok.
participants (3)
-
Alan DeKok -
Arran Cudbard-Bell -
Mustafa Nassir