We are using a squid proxy server (version 3.1.4) in our office environment on linux box. In total we are approximately 20 users and all are in one network and we have internet plan of 25GB/month. Now what we want is restrict each user to some size say 1GB/user/month (will be more better if it is more configurable, say 512MB for some users, 2GB for some users) , so that everyone get equal access.

I have searched a lot over internet like to restrict with bandwidth, or using maximum download size parameter reply_body_max_size, delay parameters. But cannot find what I want.

Is there any way to do this in squid or any other open source option?


Probably via a custom helper that squid would call, say http://wiki.squid-cache.org/Features/Redirectors that looks at the client IP, consults a database of how much bandwidth they've used (perhaps parsed from the squid logs by something else), and redirects them to a sorry page if over. This will probably require a bunch of coding, if such code does not yet exist.


According to squid wiki page user data quota is under development (see below link).

squish can be used to limit data per IP per month. (using squid)

Features/Quota - Squid Web Proxy Wiki http://wiki.squid-cache.org/Features/Quota

  • squish latest version is 0.0.18, released in 2006, which would suggest it is no longer maintained. Features/Quota shows as not started yet, no ETA and no assigned developer. – steve Aug 28 '15 at 16:20

After searching for more than a week, I found the solution in my way using html reports of sarg - Squid Analysis Report Generator, and extracting its data using simple bash script.

sarg stores its data in /var/www/sarg directory. To generate monthly report we have to manually use this command: sarg -d 01/08/2015-31/08/2015.

After this command I have written a simple script to block by ip-address which are overlimit as follows:

ip=( )
cd /var/www/sarg/$range/

for system in "${ip[@]}"; do
        size=`cat $system/$system.html | grep TOTAL | awk '{print $4}' | tr -d 'class="header2"></t.<t'| sed 's/K/0/' | sed 's/M/0000/'`
        if [ "$size" -gt "$maxsize" ]
                iptables -A INPUT -s $ip -p tcp --dport 3128 -j DROP
                iptables -A OUTPUT -s $ip -p tcp --dport 3128 -j DROP
                echo "$system blocked because data usage over $size bytes"
                echo "$system used size is $size"
service iptables save

NOTE: This script is not fully furnished as of now and have to work little more for getting all things fully automated and flexible.


I've been struggling to add this functionality as well. The problem with squish is, it's squishing users that is not supposed to be squished.

The workaround that I used was to use the daily data from lightsquid stored in /var/lib/lightsquid/report/<date>/.total. Since lightsquid data is updated every 10 minutes, it also gave my squid setup the ability of an almost "real-time" quota capability.


if you want to use SQUID only you can use NFQUEUE. you can redirect all traffic to NFQEUE first and control traffic in user space programming. Then you can decide DROP or or forward to SQUID (3128) port. You should create small prepaid charging system. see my small article for this.

But I suggest use RADIUS (dolaRadius) solution to achieve your requirement. There are possibility to integrate SQUID with FreeRADIUS and control traffic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.