Bandwidth Limit Option?

Post your questions about SoftEther VPN software here. Please answer questions if you can afford.
Post Reply
360sync
Posts: 26
Joined: Tue May 28, 2013 12:00 am

Bandwidth Limit Option?

Post by 360sync » Sat Jun 15, 2013 12:01 am

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,

cedar
Site Admin
Posts: 2070
Joined: Sat Mar 09, 2013 5:37 am

Re: Bandwidth Limit Option?

Post by cedar » Sat Jun 15, 2013 12:17 am

Traffic bandwidth limit option is in security policy setting of a user or a group.

360sync
Posts: 26
Joined: Tue May 28, 2013 12:00 am

Re: Bandwidth Limit Option?

Post by 360sync » Sat Jun 15, 2013 12:23 am

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.

cedar
Site Admin
Posts: 2070
Joined: Sat Mar 09, 2013 5:37 am

Re: Bandwidth Limit Option?

Post by cedar » Sat Jun 15, 2013 3:08 pm

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.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Sun Oct 20, 2013 7:21 am

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...

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Sun Oct 20, 2013 10:25 am

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.
Last edited by inten on Mon Oct 21, 2013 1:40 am, edited 2 times in total.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Sun Oct 20, 2013 1:38 pm

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

elborneo
Posts: 17
Joined: Fri Oct 18, 2013 8:39 am

Re: Bandwidth Limit Option?

Post by elborneo » Sun Oct 20, 2013 5:18 pm

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

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Sun Oct 20, 2013 11:40 pm

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.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Mon Oct 21, 2013 10:36 am

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

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Mon Oct 21, 2013 10:41 am

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.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

elborneo
Posts: 17
Joined: Fri Oct 18, 2013 8:39 am

Re: Bandwidth Limit Option?

Post by elborneo » Mon Oct 21, 2013 11:26 am

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

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Mon Oct 21, 2013 11:29 am

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
}
Last edited by inten on Mon Oct 21, 2013 12:48 pm, edited 1 time in total.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

elborneo
Posts: 17
Joined: Fri Oct 18, 2013 8:39 am

Re: Bandwidth Limit Option?

Post by elborneo » Mon Oct 21, 2013 12:37 pm

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 :)

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Mon Oct 21, 2013 12:49 pm

elborneo wrote:
> how to load this script?

powershell, ёпта.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Mon Oct 21, 2013 3:43 pm

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?

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Tue Oct 22, 2013 12:30 am

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?
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Tue Oct 22, 2013 8:06 am

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

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Tue Oct 22, 2013 8:48 am

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.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Mon Oct 28, 2013 1:40 am

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

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Mon Oct 28, 2013 5:47 am

skype me: ksimonenko (you this symbol here) outlook.com
Last edited by inten on Mon Oct 28, 2013 12:14 pm, edited 1 time in total.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

Ardy7201
Posts: 18
Joined: Sun Oct 20, 2013 6:58 am

Re: Bandwidth Limit Option?

Post by Ardy7201 » Mon Oct 28, 2013 7:45 am

ok. now i got it. thanks for your help in skype

now, to set limit for user "admin"

how to set in script?

inten
Posts: 370
Joined: Fri Oct 18, 2013 8:15 am
Location: All around the world
Contact:

Re: Bandwidth Limit Option?

Post by inten » Mon Oct 28, 2013 10:34 am

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.
When you don't like the answer, change the question.
Cheers,
Team.

VPNHPanel.com
This account is not associated to SoftEther project.

nickmccomb
Posts: 4
Joined: Fri Jul 14, 2017 5:48 am

Re: Bandwidth Limit Option?

Post by nickmccomb » Fri Jul 14, 2017 5:50 am

Hey guys, does anyone have this script for Linux (Ubuntu)? Would be very helpful, thank you!

nikrox
Posts: 3
Joined: Sun Aug 13, 2017 11:38 am

Re: Bandwidth Limit Option?

Post by nikrox » Tue May 08, 2018 1:41 pm

Is there a linux version of this? I'd really like to get this working.

shakibamoshiri
Posts: 285
Joined: Wed Dec 28, 2022 9:10 pm

Re: Bandwidth Limit Option?

Post by shakibamoshiri » Sat Feb 11, 2023 7:11 am

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>

Post Reply