AMP AMP

How to limit bandwidth in Squid - Part 4

To limit the bandwidth in SQUID

Squid proxy server is used to limit bandwidth usage for each user (or) for a whole network using classes. In this article we will learn how to limit bandwidth using delay class 1 and class 2.

To block with keywords and extensions in Squid visit,
https://www.linuxhelp.com/how-to-block-keywords-and-extensions-in-squid-2/

To configure Squid visit,
https://www.linuxhelp.com/how-to-configure-acl-rule-by-timing-and-browser-in-squid/

To limit bandwidth in Squid visit,
https://www.linuxhelp.com/how-to-limit-bandwidth-squid/

Class 1 type delay

Configuring the limitation of bandwidth using class 1 delay. In this we have to mention the delay pool. Delay pools allows you to limit the traffic for clients.

syntax :

acl test src single_ipaddress (or) network_address
delay_pools total_poolcount
delay_class pool class_type
delay_parameters pool aggregate

Open the config file located in /etc/squid/

[root@linuxhelp~]# vim /etc/squid/squid.config

Add the following lines into it.

acl test src 192.168.5.219 192.168.5.63    192.168.7.219
delay_pools 1
delay_class 1 1
delay_parameters 1 8000/8000
delay_access 1 allow test

Explanations

  • Mention the source acl name as “ test” , entered the IP addresses.
  • Mention “ delay_pools “ and next 1 indicates,only one pool is to be created.
  • Mention “ delay_class” . Here, the first 1 indicates pool count order and the second 1 indicates the class type.
  • Mention “ delay_parameters” and next 1 indicates pool count order and next is the maximum allowable bandwidth usage(64kbps) for the IP’ s comes under the acl name test.
  • Mention “ delay_access” and 1 is the pool count order and next is “ allow test” .

Calculation to get the aggregate value

For 64kbps = (64/8)*1000 = 8000

Restart the Squid services

[root@linuxhelp ~]# service squid reload

In the below snap, you can see the download takes much time


Class 2 type delay

Now Configure the limitation of bandwidth using class 2 delay.

syntax
acl test src network_address
delay_pools total_poolcount
delay_class pool class_type
delay_parameters pool aggregate individual

Open the config file located in /etc/squid/

[root@linuxhelp~]# vim /etc/squid/squid.config


Add the following lines into the config file.

acl test sec 192.168.5.0/24
delay_pools 1
delay_class 1 2 
delay_parameters 1 256000/256000 64000/64000
delay_access 1 allow test


Explanation

  • Mention the source acl name as “ test” , entered the IP addresses.
  • Mention the “ delay_pools “ and next 1 indicates,only one pool is to be created.
  • Mention the “ delay_class” .Here the first 1 indicates pool count order and the 2 indicates the class type 2.
  • Mentioned “ delay_parameters” and next 1 indicates pool count order and next is the maximum allowable overall bandwidth (2Mbps) for the 192.168.5.0/24 network. The next(512kbps) is the maximum allowable bandwidth for individual IP comes under the network.

Restart the Squid services

[root@linuxhelp ~]# service squid reload

Open the browser and start the download. You can see that the download speed is limited as per the rule mentioned.

Tag : Squid
FAQ
Q
What is main terms of using the "Squid"?
A
Squid is a high-performance proxy caching server for web clients, supporting FTP, gopher, and HTTP data objects. Unlike traditional caching software, Squid handles all requests in a single, non-blocking, I/O-driven process.

Squid keeps meta data and especially hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests.

Squid supports SSL, extensive access controls, and full request logging. By using the lightweight Internet Cache Protocol, Squid caches can be arranged in a hierarchy or mesh for additional bandwidth savings.
Q
What is Internet object caching?
A
Internet object caching is a way to store requested Internet objects (i.e., data available via the HTTP, FTP, and gopher protocols) on a system closer to the requesting site than to the source. Web browsers can then use the local Squid cache as a proxy HTTP server, reducing access time as well as bandwidth consumption.
Q
What Operating Systems does Squid support?
A
The software is designed to operate on any modern Unix system, and is known to work on at least the following platforms:

Linux
FreeBSD
NetBSD
BSDI
OSF and Digital Unix
IRIX
SunOS/Solaris
NeXTStep
SCO Unix
AIX
HP-UX
OS/2
Q
Does Squid run on Windows NT?
A
Recent versions of Squid will compile and run on Windows/NT with the GNU-Win32 package.

However, Squid does not yet perform well on Windows/NT.
Q
Does Squid support SSL?
A
Squid can proxy SSL requests. By default, Squid will forward all SSL requests directly to their origin servers. In firewall configurations, Squid will forward all SSL requests to one other proxy, defined with the ssl_proxy directive.