OpenWrt Forum Archive

Topic: quota and bandwidth report

The content of this topic has been archived on 31 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all
I need quota limiting and bandwidth report feature for eatch user on my network
gargoyle is based on openwrt so i think i can have that on openwrt
please help me
and another question I have tp-link r470t load balancing
is this support openwrt? how?
please help me
Best Regards

(Last edited by nicolase on 13 Nov 2016, 22:46)

There are numerous packages available for this. You could try bandwidthd (in the packages repository). You will need to have a non-volatile memory area available to store the data.

You have only one router, or multiple routers? If you have multiple routers (which I think is the case because you ask about load balancing), then your solution is more complex. For a large network, you're probably better off using netflow. I use netflow on my network: softflowd can do netflow v9 and export flows to a server on your network. In my case I use Silk to collect the netflow data and have a number of scripts that use the Silk tools to extract the data I need. Netflow data is very granular.

Quota limiting is a separate subject. There is no out-of the-box solution that I am aware of. Implementing this on a per-user level could be relatively easy if you have 5 users, or very complicated if you have 1,000 users. Simple versions of quota limiting are typically accomplished using iptables rules to track the bytes transferred and then block or pass the traffic.

thanks alot for your reply
would you please give me some informations and how can i use iptables?
i'm new in openwrt
please help
Best Regards

dl12345 wrote:

Quota limiting is a separate subject. There is no out-of the-box solution that I am aware of. Implementing this on a per-user level could be relatively easy if you have 5 users, or very complicated if you have 1,000 users. Simple versions of quota limiting are typically accomplished using iptables rules to track the bytes transferred and then block or pass the traffic.

(Last edited by nicolase on 14 Nov 2016, 11:46)

nicolase wrote:

thanks alot for your reply
would you please give me some informations and how can i use iptables?
i'm new in openwrt
please help
Best Regards

dl12345 wrote:

Quota limiting is a separate subject. There is no out-of the-box solution that I am aware of. Implementing this on a per-user level could be relatively easy if you have 5 users, or very complicated if you have 1,000 users. Simple versions of quota limiting are typically accomplished using iptables rules to track the bytes transferred and then block or pass the traffic.

This is a very short question but a very long answer. OpenWrt uses iptables, which is standard Linux, so any Linux resource on iptables would be appropriate reading. There is a lot of material on the internet regarding using iptables to implement quotas. Suggest you Google and read. If you're new to iptables, you have a significant learning curve ahead of you because I would regard quotas as a fairly advanced iptables topic.

Hi
thanks again for your reply
I tested bandwidth but I think it's not what I'm looking!
I downloaded 1GB for testing but it shows 170MB! an I'm looking for showing in hours!
I found ntop in openwrt wiki but don't know how can I config that and bandwidth uses more CPU
How can I install ntop?
if you thing I'm rong or bandwidth or etc is better than ntop please help
My router is 1043nd v1.0
Best Regards!

dl12345 wrote:

There are numerous packages available for this. You could try bandwidthd (in the packages repository). You will need to have a non-volatile memory area available to store the data.
.

(Last edited by nicolase on 18 Nov 2016, 03:00)

Ntop is now a commercial package. Softflowd is better as the collector. I use Silk as the backend.

This is a complicated subject. Any installation guide would take many pages to write. There are already several guides on the internet

softflowd is available as a package in the OpenWrt repository. It does the same as the ntop probe, that is to say it is a netflow probe or netflow exporter.

A netflow probe exports netflow format data to a netflow collector/analyzer. You need to setup the collector on a separate computer.

Here is documentation on how to setup Silk on Centos 7

Oh - if bandwidthd is showing you download only 170MB when you download 1GB, you're almost certainly looking at the flows in the wrong direction (ie, upload data and not download data)

(Last edited by dl12345 on 18 Nov 2016, 10:21)

I am using iptables to fetch upload/download data per IP address and saving data in a non-volatile area so that data doesn't reset on reboots which in turn doesn't need any extra packages to be installed on router and saves disk space

(Last edited by nbuser on 18 Nov 2016, 11:33)

Just use gargoyle it has all the things you are asking for. Stop trying to reinvent the wheel. big_smile

Hi
Thanks for your reply
I installed ntop on virtual machin for my university lessons (I'm IT engineering student)
for example may I install ntop like virtual machin?
or it does not detect openwrt
I assked because openwrt is based on linux like ntop
please help me
Best Regards!

dl12345 wrote:

Ntop is now a commercial package. Softflowd is better as the collector. I use Silk as the backend.

This is a complicated subject. Any installation guide would take many pages to write. There are already several guides on the internet

softflowd is available as a package in the OpenWrt repository. It does the same as the ntop probe, that is to say it is a netflow probe or netflow exporter.

A netflow probe exports netflow format data to a netflow collector/analyzer. You need to setup the collector on a separate computer.

Here is documentation on how to setup Silk on Centos 7

Oh - if bandwidthd is showing you download only 170MB when you download 1GB, you're almost certainly looking at the flows in the wrong direction (ie, upload data and not download data)

Hi
Thanks for your reply
would you please give me more information about iptables?
Best Regards!

nbuser wrote:

I am using iptables to fetch upload/download data per IP address and saving data in a non-volatile area so that data doesn't reset on reboots which in turn doesn't need any extra packages to be installed on router and saves disk space

Hi
Thanks for your reply
I tried gargoyle it was perfect
but I need 2 featurs that is not in gargoyle:
1- using 2 wans
2- download manager
please help me
Best Regards

tapper wrote:

Just use gargoyle it has all the things you are asking for. Stop trying to reinvent the wheel. big_smile

I am using TPlink 3220 and we all are aware of space issue it has. Thus to avoid space crunch, I have created my own customized dashboard and it doesnt use any third party softwares to perform basic tasks. At backend its only using iptables. Thus necessity is mother of invention and sometimes we do need to reinvent the wheel...:)

PFA screenshot: https://drive.google.com/file/d/0B6mvTV … sp=sharing

(Last edited by nbuser on 21 Nov 2016, 06:32)

Thanks alot for your reply
would you please give me some instruction about how you did it?
I'm looking something loke this
please help
Best Regards

nbuser wrote:

I am using TPlink 3220 and we all are aware of space issue it has. Thus to avoid space crunch, I have created my own customized dashboard and it doesnt use any third party softwares to perform basic tasks. At backend its only using iptables. Thus necessity is mother of invention and sometimes we do need to reinvent the wheel...:)

PFA screenshot: https://drive.google.com/file/d/0B6mvTV … sp=sharing

Its a result of shell scripting and html. My dashboard scripts can perform below functions:

1. Monitor wifi connections and alert for any outsider mac address connections via email.
2. Monitor my WAN connection and auto login in webpage to activate internet. My ISP requires me to login in webpage at regular interval.
3. Control bandwidth and maintain quota usage even if router reboots, data isn't lost.
4. Blocks internet of my allowed guest logins at specified interval
5. Maintains per day bandwidth usage of each ip address
6. Reset iptables counters every 1st of month to get exact usage of each ip address.
7. Takes backup of log files daily on SD card and by the way my SD card isn't always ON. USB power is activated to take backup and turned off when backup is done.
8. Every thing is running in RAM and SD card is not in use.

(Last edited by nbuser on 21 Nov 2016, 13:27)

Thanks for your reply
I'm sorry I'm new in this matter
may I have your script for my usage please? or atleast would you guid me how can I create sth with that?
Thanks alot
Best Regards!

nbuser wrote:

Its a result of shell scripting and html. My dashboard scripts can perform below functions:

1. Monitor wifi connections and alert for any outsider mac address connections via email.
2. Monitor my WAN connection and auto login in webpage to activate internet. My ISP requires me to login in webpage at regular interval.
3. Control bandwidth and maintain quota usage even if router reboots, data isn't lost.
4. Blocks internet of my allowed guest logins at specified interval
5. Maintains per day bandwidth usage of each ip address
6. Reset iptables counters every 1st of month to get exact usage of each ip address.
7. Takes backup of log files daily on SD card and by the way my SD card isn't always ON. USB power is activated to take backup and turned off when backup is done.
8. Every thing is running in RAM and SD card is not in use.

Please Help

nbuser wrote:

Its a result of shell scripting and html. My dashboard scripts can perform below functions:

1. Monitor wifi connections and alert for any outsider mac address connections via email.
2. Monitor my WAN connection and auto login in webpage to activate internet. My ISP requires me to login in webpage at regular interval.
3. Control bandwidth and maintain quota usage even if router reboots, data isn't lost.
4. Blocks internet of my allowed guest logins at specified interval
5. Maintains per day bandwidth usage of each ip address
6. Reset iptables counters every 1st of month to get exact usage of each ip address.
7. Takes backup of log files daily on SD card and by the way my SD card isn't always ON. USB power is activated to take backup and turned off when backup is done.
8. Every thing is running in RAM and SD card is not in use.

what is your router model? I have created these scripts as per my model tplink mr3220.

Thanks for your reply
My router is:
tplink wr1043nd
Best Regards!

nbuser wrote:

what is your router model? I have created these scripts as per my model tplink mr3220.

what do you mean by "how can I create sth with that?"

I mean how can create report page like your screenshot with IPtables
I'm new in IPtables
may I have your source code?
does it work on wr1043nd?
Best Regards

nbuser wrote:

what do you mean by "how can I create sth with that?"

please help

nicolase wrote:

I mean how can create report page like your screenshot with IPtables
I'm new in IPtables
may I have your source code?
does it work on wr1043nd?
Best Regards

nbuser wrote:

what do you mean by "how can I create sth with that?"

What I did to monitor ~10 users on my OpenWrt

Installed pivot overlay with a USB stick, as my router's storage is too small to install the packages and store the bandwidth data. wiki.openwrt.org/doc/howto/extroot

Installed luci-app-statistics with collectd-mod-iptables.  wiki.openwrt.org/doc/howto/luci_app_statistics

Setup a custom iptables settings;

iptables -N TRAFFIC_ACCT_IN
iptables -N TRAFFIC_ACCT_OUT

iptables -I FORWARD -i pppoe-wan -j TRAFFIC_ACCT_IN
iptables -I FORWARD -o pppoe-wan -j TRAFFIC_ACCT_OUT

iptables -A TRAFFIC_ACCT_IN --dst 192.168.1.150 -m comment --comment "user1-in"
iptables -A TRAFFIC_ACCT_OUT --src 192.168.1.150 -m comment --comment "user1-out"

Setup Static Leases for clients; MAC 00:11:22:33:44:FF -> 192.168.1.150

Setup collectd-mod-iptables rule; name: user1-in options: user1-in

Point luci-app-statistics database to a folder in USB

That should be it, also check this out, I've learnt from there; catonmat.net/blog/traffic-accounting-with-iptables

edit: add-usb

(Last edited by Kitin on 26 Nov 2016, 20:25)

The discussion might have continued from here.