by September 17, 2003 0 comments



You can use Squid to optimize Internet sharing. Some things that should be done are restricting heavy downloads, allocating preferntial bandwidth and caching Web pages. 

Configure Squid 
Squid gets installed when you install PCQlinux 8.0 using the Gateway option. By default, it denies all http traffic. To enable it, you need to run Webmin. Type http://<server_IP>:10000, where <server_IP> is the IP address of your Linux box running Squid. Give root as user name and leave the password field blank. Select SERVERS>Squid Proxy server and click on the ‘Access control’ icon. This will display all rules for incoming/outgoing traffic. Under the ‘Proxy restriction’ list, click on a rule called ‘Deny all’. Set it to ‘Allow’ and then click on the ‘Save’ button. Now, from the Webmin menu, click on ‘Apply changes’ and restart Squid by stopping and then starting the service. By default, Squid runs on port 3128.

Restrict heavy downloads 
To restrict the downloading of heavy files, such as MP3s and movies, edit the squid.conf from /etc/squid/squid.conf and add the following lines.

delay_pool 2
delay_parameters 2 5000/150000 5000/10000
acl magic_word1 url_regex -i ftp .mp3 .mov .avi .ram
delay_access 2 allow magic_word1

The first command creates a delay pool numbered 2. Similarly, you can create multiple delay pools for different requirements. The second line limits bandwidth usage. 5000/150000 means that when the total downloads for all users on the network exceed 150000 bytes, then it should limit the bandwidth to 5000 bytes per second for all. 5000/10000 specifies the same for individual IP addresses. The third line is meant to block downloads for files with extensions such as MP3 and MOV. In this, ‘acl’ means access-control list, which has been named magic_word1. The last line limits the bandwidth of delay pool 2 to what’s given in the delay parameters in the second line, for all extensions given in the third line. 

Allocate preferential bandwidth
In the delay pool in Squid, the default bandwidth allocation to users is 50%. This means that if you have a 512 kbps connect to the Internet, then the maximum bandwidth available to all users will be 50% of that or 256 kbps. You can, however, change this percentage. To do so, go to the Squid proxy configuration through Webmin, select ‘Delay pool’ and go to the ‘Global’ text box. You can set your percentage there. (For more on bandwidth management, see Bandwidth Management Using Squid, page 96, PCQuest August 2003.)

Another example of allocating preferential bandwidth is to restrict the use of Kazaa and other P2P applications. You can control how much bandwidth to keep for these apps; you can even completely block them. As an example, let’s say you want to allocate only 1 kbps bandwidth to Kazaa. For that, create a file name cbq-10.eth0 in the directory /etc/sysconfig/cbq and add the lines given below.

DEVICE=eth0,110Kbit
RATE=1Kbit
WEIGHT=2Kbit
PRIO=5
RULE=,:21
RULE=,213.25.25.101
RULE=,:1214
RULE=,:41000
#add till 41030

Here, the key things to note are the IP address for Kazaa downloads (213.25.25.101) and the various ports it uses to download (1214, 41000 to 41030). Plus, 21 is the default port for ftp, which Kazaa uses to search on the Internet for downloads. Finally, 1 Kbit is the download speed you’re limiting for Kazaa downloads. Save this file and reboot your machine for changes to take place. 

Cache Web pages
When you install Squid, Web caching is disabled by default. To activate it (which you must do), click on the option called ‘Initialize cache’ from the Webmin menu and click on ‘Start squid’. 

Sanjay Majumder

No Comments so far

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.

Your data will be safe!Your e-mail address will not be published. Also other data will not be shared with third person.