Page 1 of 1

Bandwidth Limit Option?

Posted: Sat Jun 15, 2013 12:01 am
by 360sync
Hello,

I've cruised through the options and have not found one to set a limit, such as allocating 50GB on a plan. A user gets 50GB and if limit is reach the session is disconnected.

Is there such an option or any insight on a possible solution would be appreciated.

Thank you,

Re: Bandwidth Limit Option?

Posted: Sat Jun 15, 2013 12:17 am
by cedar
Traffic bandwidth limit option is in security policy setting of a user or a group.

Re: Bandwidth Limit Option?

Posted: Sat Jun 15, 2013 12:23 am
by 360sync
Yes there is a limit for the speed(bps)- however not seeing one for the amount of traffic, such as a client downloading 50GB on a plan over a month per say.

Re: Bandwidth Limit Option?

Posted: Sat Jun 15, 2013 3:08 pm
by cedar
There is no traffic amount limitation function in VPN server.
But traffic amount per user is visible in user profile.
You can make a batch to disable user account when traffic amount exceeds limit.

Re: Bandwidth Limit Option?

Posted: Sun Oct 20, 2013 7:21 am
by Ardy7201
cedar wrote:
> There is no traffic amount limitation function in VPN server.
> But traffic amount per user is visible in user profile.
> You can make a batch to disable user account when traffic amount exceeds
> limit.

but how to create a batch?

same problem here. i need to set example 25gb quota limit each user. but no option. just speed limit option...

Re: Bandwidth Limit Option?

Posted: Sun Oct 20, 2013 10:25 am
by inten
Ardy7201 wrote:

> but how to create a batch?
> same problem here. i need to set example 25gb quota limit each user. but no option.
> just speed limit option...

You may use the vpncmd shell.

Re: Bandwidth Limit Option?

Posted: Sun Oct 20, 2013 1:38 pm
by Ardy7201
inten wrote:
> Ardy7201 wrote:
>
> > but how to create a batch?
> > same problem here. i need to set example 25gb quota limit each user. but no
> option.
> > just speed limit option...
>
> You may use the vpncmd shell.


but how? sorry newbie here

Re: Bandwidth Limit Option?

Posted: Sun Oct 20, 2013 5:18 pm
by elborneo
that's a good idea for the next feature :)
by the way.. i need it too,
some one please give us some clue using vpncmd

Re: Bandwidth Limit Option?

Posted: Sun Oct 20, 2013 11:40 pm
by inten
elborneo wrote:
> that's a good idea for the next feature :)
> by the way.. i need it too,
> some one please give us some clue using vpncmd

We are currently cooking such script, please wait, will publish it here.

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 10:36 am
by Ardy7201
inten wrote:
> elborneo wrote:
> > that's a good idea for the next feature :)
> > by the way.. i need it too,
> > some one please give us some clue using vpncmd
>
> We are currently cooking such script, please wait, will publish it here.

thank you very much! im waiting the script...

im still new on hot to manage client, client info, server in batch

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 10:41 am
by inten
Ardy7201 wrote:

> thank you very much! im waiting the script...

Please be patient! This script is a part small part of our VPN Hosting Management solution and it needs to be adopted to run solely.

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 11:26 am
by elborneo
inten wrote:
> Ardy7201 wrote:
>
> > thank you very much! im waiting the script...
>
> Please be patient! This script is a part small part of our VPN Hosting Management
> solution and it needs to be adopted to run solely.

thanks inten..
i hope you can also provide us some option to set the connection timeout manualy to vpn client, that would be great to solve my problem here http://www.vpnusers.com/viewtopic.php?f=7&t=2330

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 11:29 am
by inten
Here we go.
This powershell script moves the users with exceeding amount of $Limit(bytes) to Disabled_Users group, where you can assign any policy you need to block. Please take a closer look at the params in the vpncmd string, you need to change them accordingly. Also please note this script counts incoming traffic only and if you need overall traffic you also need to change it in the script.
Do not hesitate if you need smth.

$Limit = 10737418240 // in bytes
$Password = "print pass here"
$result = Invoke-Expression -command "vpncmd /server localhost /hub:DEFAULT /password:$Password /cmd:UserList"
$regex = new-object System.Text.RegularExpressions.Regex("User Name\s*\|\s*(.*?)\s")
foreach($match in $regex.Matches($result))
{
$username = $match.Groups[1].Value
$result = Invoke-Expression -command "vpncmd /server localhost /hub:DEFAULT /password:$Password /cmd:UserGet $username"
$regexUnicast = new-object System.Text.RegularExpressions.Regex("Outgoing Unicast Total Size\s*\|\s*([,\d]+)\s+bytes")
$regexBroadcast = new-object System.Text.RegularExpressions.Regex("Outgoing Broadcast Total Size\s*\|\s*([,\d]+)\s+bytes")
$totalOutgoing = [int]$regexUnicast.Match($result).Groups[1].Value.Replace(",", "") + [int]$regexBroadcast.Match($result).Groups[1].Value.Replace(",", "")
$regexUnicast = new-object System.Text.RegularExpressions.Regex("Incoming Unicast Total Size\s*\|\s*([,\d]+)\s+bytes")
$regexBroadcast = new-object System.Text.RegularExpressions.Regex("Incoming Broadcast Total Size\s*\|\s*([,\d]+)\s+bytes")
$totalIncoming = [int]$regexUnicast.Match($result).Groups[1].Value.Replace(",", "") + [int]$regexBroadcast.Match($result).Groups[1].Value.Replace(",", "")
Write-Host ("User " + $username)
Write-Host ("Total incoming: " + $totalIncoming + " bytes")
Write-Host ("Total outgoing: " + $totalOutgoing + " bytes")
if ($totalIncoming -ge $Limit)
{
Invoke-Expression -command "vpncmd /server localhost /hub:DEFAULT /password:$Password /cmd:GroupJoin 'Disabled_Users' /username:$username"
Write-Host "User Moved"
}
Write-Host
}

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 12:37 pm
by elborneo
inten wrote:
> Here we go.
> The script moves the users with exceeding amount of $Limit(bytes) to
> Disabled_Users group, where you can assign any policy you need to block.
> Please take a closer look at the params in the vpncmd string, you need to
> change them accordingly. Also please note this script counts incoming
> traffic only and if you need overall traffic you also need to change it in
> the script.
> Do not hesitate if you need smth.

how to load this script?

sorry.. newbie question :)

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 12:49 pm
by inten
elborneo wrote:
> how to load this script?

powershell, ёпта.

Re: Bandwidth Limit Option?

Posted: Mon Oct 21, 2013 3:43 pm
by Ardy7201
inten wrote:
> elborneo wrote:
> > how to load this script?
>
> powershell, ёпта.

even how to you use powershell? please make some tutorial. step by step. easy mode. newbie here. how to apply the script. incoming traffic only? how to change to total overall traffic by user?

Re: Bandwidth Limit Option?

Posted: Tue Oct 22, 2013 12:30 am
by inten
Ardy7201 wrote:

> even how to you use powershell? please make some tutorial. step by step. easy mode.
> newbie here. how to apply the script. incoming traffic only? how to change to total
> overall traffic by user?

What is yr OS?

Re: Bandwidth Limit Option?

Posted: Tue Oct 22, 2013 8:06 am
by Ardy7201
inten wrote:
> Ardy7201 wrote:
>
> > even how to you use powershell? please make some tutorial. step by step. easy mode.
> > newbie here. how to apply the script. incoming traffic only? how to change to total
> > overall traffic by user?
>
> What is yr OS?

WIn 7 64 bit. thanks bro

Re: Bandwidth Limit Option?

Posted: Tue Oct 22, 2013 8:48 am
by inten
Don't get me wrong but I don't know how to explain you the way to run PowerShell (powershell.exe). Just save the script into a file, save it with .ps1 extension and then run it from powershell, don't forget to edit to run on your system.
Please understand that currently I have no enough free time to write a whole tutorial for small script. It would be better you could ask here if you need something, I will try to help.

Re: Bandwidth Limit Option?

Posted: Mon Oct 28, 2013 1:40 am
by Ardy7201
inten wrote:
> Don't get me wrong but I don't know how to explain you the way to run
> PowerShell (powershell.exe). Just save the script into a file, save it with
> .ps1 extension and then run it from powershell, don't forget to edit to run
> on your system.
> Please understand that currently I have no enough free time to write a
> whole tutorial for small script. It would be better you could ask here if
> you need something, I will try to help.

ok.
Windows 7 64bit

step 1 : http://prntscr.com/207h1s
step 2 (just paste the script to powershell?) : http://prntscr.com/207h9q
step 3 (save the script in notepad a.ps1 and load with powershell) : http://prntscr.com/207hn3
ste* 4 : http://prntscr.com/207hva
step 5 (error execute script on system) : http://prntscr.com/207i31
step 6 (enable the script execution on win 7) :
Try the following steps and check if it helps:
a) Right-click your PowerShell icon and select Run as administrator.
b) Check the current script execution policy by using the Get-ExecutionPolicy cmdlet. To do this, input “Get-ExecutionPolicy” (without quotes) and press Enter on your keyboard. PowerShell will return a value of Restricted.
c) To change the script execution policy, use the Set-ExecutionPolicy cmdlet. Input “Set-ExecutionPolicy unrestricted” (without quotes) and press Enter on your keyboard.
d) To ensure that the script execution policy has been changed, use the Get-ExecutionPolicy cmdlet again. PowerShell should return a value of Unrestricted.
e) You should now be able to run your PowerShell scripts.

still dont work

Re: Bandwidth Limit Option?

Posted: Mon Oct 28, 2013 5:47 am
by inten
skype me: ksimonenko (you this symbol here) outlook.com

Re: Bandwidth Limit Option?

Posted: Mon Oct 28, 2013 7:45 am
by Ardy7201
ok. now i got it. thanks for your help in skype

now, to set limit for user "admin"

how to set in script?

Re: Bandwidth Limit Option?

Posted: Mon Oct 28, 2013 10:34 am
by inten
Ardy7201 wrote:
> ok. now i got it. thanks for your help in skype
>
> now, to set limit for user "admin"
>
> how to set in script?

this script cannot set limits for different users, you can apply user a group that has some limitations even to disconnect.

Re: Bandwidth Limit Option?

Posted: Fri Jul 14, 2017 5:50 am
by nickmccomb
Hey guys, does anyone have this script for Linux (Ubuntu)? Would be very helpful, thank you!

Re: Bandwidth Limit Option?

Posted: Tue May 08, 2018 1:41 pm
by nikrox
Is there a linux version of this? I'd really like to get this working.

Re: Bandwidth Limit Option?

Posted: Sat Feb 11, 2023 7:11 am
by shakibamoshiri
From now it is possible
You can use secli
https://github.com/shakibamoshiri/secli
it gives you a report for a user traffic
- have
- used
- rest
and when "rest" became negative, it means that user has exceeded the limitation.
So simply disable the user
secli user --disable <SERVER> <HUB> <USERNAME>