Faster Internet With an Old Laptop – Ubuntu and Squid

Jun 2, 2009 by

I’ve posted more than once about tips we can complete to improve our web surfing. This morning I was cleaning out some old hardware (to take to the recycling centre) when I happened upon one of the last old laptops I had.

It’s an older IBM Thinkpad T22, Type 2647 with 256MB of RAM and a 20GB hard drive. A couple years ago, I had 2o of these units, bought from a recycling depot. I sold them all on eBay, and only have a couple left now.

IBM Thinkpad T22

Whilst packing up the stuff to cart off, it occurred to me that I could put this old laptop to work by installing a proxy / caching server on it, and have my we browsers, pull much of the regularly requested web content off a locally cached network server. This means installing Squid. Not sure what Squid is: Squid (software), from their site:

“…Squid is a proxy server and web cache daemon. It has a wide variety of uses, from speeding up a web server by caching repeated requests, to caching web, DNS and other computer network lookups for a group of people sharing network resources, to aiding security by filtering traffic. Although primarily used for HTTP and FTP, Squid includes limited support for several other protocols including TLS, SSL, Internet Gopher and HTTPS. The development version of Squid (3.1) includes IPv6 and ICAP support…”

Needless, as I currently enjoy using Ubuntu, that’s what I used as the OS for this project. Installing a Squid server on the network, provided me with a few important benefits:

  • Less bandwidth usage.
  • Faster web surfing.
  • Network cached copies of pages I regularly visit (if the original server is down).

Firstly, make sure you’ve installed a copy of Ubuntu 8.04 Server (Hardy) on the old laptop. Not sure how to do that? Here’s a guide: The Perfect Server – Ubuntu Hardy Heron (Ubuntu 8.04 LTS Server). In my case I skipped (did not install) Apache, MySQL, Postfix, BIND9, Proftpd, POP3/IMAP and Webalizer. I don’t need those, I only need the Squid proxy / caching server. I also installed Webmin (see below), so that I can easily manage this server remotely. A word to the wise however, I found out (about 2 years ago) to install Squid first! – That way the Webmin installation goes much smoother (I was using Debian for the server  at that time, and Ubuntu in another instance). Also, for those of you who have been following my blog (and for my welcomed new readers), I also played with Squid and Ubuntu about a year ago, in this post: Speed Up and Improve Web Surfing With an Ubuntu Squid Server. My earlier Ubuntu, Squid post was based on Ubuntu 6.06LTS and Squid 2.6 – Things have changed and applications, etc. have improved, so I though a revisit and reinstallation of the Squid server was in order.

I downloaded and burned a copy of the Ubuntu 8.04 LTS Server from Ubuntu’s official site at: http://www.ubuntu.com/getubuntu/download-server. The bare minimum requirements are:

300 MHz x86 processor
64 MB of system memory (RAM)
At least 4 GB of disk space (for full installation and swap space)
VGA graphics card capable of 640×480 resolution
CD-ROM drive or network card

256MB of RAM, made the install slower than I’m used to. You can find more requirements info for Ubuntu Server (Hardy) at Ubuntu System Requirements.

After downloading, and burning a copy of the ubuntu-8.04.2-server-i386 CD, complete a base install of Ubuntu server (using the howtoforge.com guide above as a reference). I also installed an SSH server so that I could tuck the old laptop away and complete everything else in  comfort,  using my desktop.

sudo aptitude install ssh openssh-server

will get the ssh server up and running for you.

Throughout this post, you’ll need to substitute your IP addresses and names to match those in your own network. After the installation of the base server is complete, open a terminal from your (comfortable) desktop and enter:

ssh root@192.168.1.200

192.168.1.200 is the address of  there server I just installed.

Use the command:

su

to enter root. That way I don’t have to keep typing “sudo”.

Install Squid usingthe command:

aptitude install squid3

After Squid has finished installing and you’ve rebooted the system, you may want to install Webmin, a GUI interface to manage that server, still in terminal, you can download a copy of the webmin package into and directory you like. The command to download is:

wget http://prdownloads.sourceforge.net/webadmin/webmin-1.470.tar.gz

Untar it like this:

tar xzvf webmin-1.470.tar.gz

Webmin needs perl to run, so I installed some packages:

aptitude install install libauthen-pam-perl libnet-ssleay-perl libpam-runtime openssl perl perl-modules

Enter my extracted contents of the webmin-1.470.tar.gz package  by:

cd webmin-1.470

And run the installation for webmin:

./setup.sh

I changed the port number away from 10000 to 26395. I changed the admin account to “root”, and entered a new password.

At the end of the webmin installation, I got the success message that include the URL: http://squid.localdomain:26395/

On my local PC, I had to edit my hosts file like this:

sudo gedit /etc/hosts

Then added the following line:

192.168.1.200 squid.localdoman    squid

Now we want to reboot the squid server using:

shutdown -r now

After rebooting the server and logging back in (via ssh), you can see if the webmin service is running by using the command:

sudo /etc/init.d/webmin status

You should see something like:

webmin (pid 4573) is running

To see if it is listening on the correct port number, the command to check that is:

sudo netstat -tap

You should find a line in the output of the above command that says something like:

tcp    0    0 *:26395    *:*    LISTEN    4573/perl

(Remember, port 26395 was the one we chose to tun webmin on – And webmin uses perl).

Now open a web browser and visit webmin. The URL I would use is:

http://squid.localdomain:26395/

(Again, remember that I added the appropriate information to my hosts file so that the browser can find the URL).

I chose not to enable SSL for logging into webmin (as I don’t need it in this LAN). After logging in, we want to configure squid. Look for something (on the left) that says “Unused Modules” and look for “Squid Proxy Server“, click that link. You will see an option to install the squid (webmin) module. Select that link to install it.

After installing, look on the left side menu and under “Servers” you will see “Squid Proxy Server“. Select “Squid Proxy Server” and then select the “Ports and Networking” option.

Note that squid is running on the default port 3128. Now return back to the squid module page by clicking “Module Index” (at the top of the page). Select the “Access Control” icon and see a button at the bottom of the page that says “Browser Regexp” – That contains a drop down list. Use the drop down list to select “Client Address” then click the button that says “Create new ACL“.

Enter your values in the form. I used the following:

ACL Name: localdomain
From IP: 192.168.1.0
To IP: 192.168.1.255
Netmask: 255.255.255.0

I didn’t change anything else and clicked on “Save”.

Now click the tab (at the top) that says “Proxy restrictions“. Click (at the bottom) “Add proxy restrictions” and look for the new ACL name you just created (mine was called “localdomain”) *** Make sure you are looking under the column that says “Match ACLS” *** and click on that name. Now click the radio button that says “Allow“. Then select “save” at the bottom.

In the new screen that display, use the up arrow to move “localdomain” (or whatever you called your new ACL rule) so that it is just above the line that says “Deny all”. If you don’t, your browsers will not be able to get access.

Now in your ssh window, use the command:

shutdown -r now

This will restart the server and squid3 (along with then new configuration). I noticed that webmin (for some strange reason) thought squid 2.6 was installed. Therefore, webmin was unable to start the server. But after rebooting the system, the “Stop Squid” button appeared – so I assume the webmin module has started working properly (no need for me to play with webmin again, as I’ll use SSH to access and reboot, etc., so I did not try).

As a final step, make sure that you set the proxy server address in your web browser. In my case the information to enter as a proxy server for each web browser is:

192.168.1.200:3128

Update, July 03, 2009: I found a problem when trying to access statistics. Here’s the issue and fix…

Issue:  When trying to access the “Cache Manager Statistics” under “Squid Proxy Server”, the following error displays:

“The Squid cache manager program /usr/lib/cgi-bin/cachemgr.cgi was not found on your system. Maybe your module configuration is incorrect.”

Fix:  aptitude install squid-cgi

Cache manager statistics will now work.

Other sites with related information:

Enjoy faster web surfing as less external files are requested for pages you commonly visit and local cached copies are delivered to your browser. I hope you ladies and gents have fun playing with this, as I hope this post helps you out. Questions, suggestions, corrections, even additions?…. Please feel free to add them to you comments!

9 Comments

  1. Nice one dude, I have an old laptop dying in some closet, time to put it to use.
    I wonder if Slitaz could be used for the endeavour…

  2. Jady L.

    I have a T22 it’s laying around gathering dust. Now I’m going to be a sexy Linux mama! Talk nerdy to me!

  3. This is really nice. I’m using squid and dansguardian to help out a school with a super tight budget get faster filtered internet access. I donated a spare PC and it’s been brilliant. As most students search google for the same terms and hit the first 10 or so links there all surfing the same pages. Internet usage has gone down and the speed has increased.

  4. The command to restart Squid (for those who need it) is:

    sudo /etc/init.d/squid restart

  5. To restart Squid, the command is:

    /etc/init.d/squid restart

  6. atss

    “This will restart the server and squid3 (along with then new configuration). I noticed that webmin (for some strange reason) thought squid 2.6 was installed.”

    The reason is that you have also installed squid3 AND 2.6. 2.6 was installed via webmin because it is not configured by default to find squid3

    I think you should correct this procedure so that you correctly configure webmin to use squid3 by going to module configuration and changing to squid3 paths. Avoid installing Squid via webmin cause it will install Squid 2.6 regardless if you have squid 3 installed

    • @atass

      Oh oh… Thanks for the heads up. I’ll have to go through the file system to check (I haven’t browsed the files for a while now) and find Squid3, to switch the pathing to it.

      Thanks muchly for the help!
      :)

  7. atss

    @UbuntuLinuxHelp

    No problem. I would not bother switching paths now as you already have it all up and running for squid 2.6 .

    If you want to use squid3, then you also have to move your squid.conf file from /etc/squid/squid.conf (squid 2.6)
    to /etc/squid3/squid.conf (squid3)
    to keep the same settings as you had before.
    Then I would remove squid and keep squid3.

    Check if squid3 is running as service by looking at the /var/log/squid3/cache.log

    Also if webmin is looking for the “squid” executable, I think the correct one is called “squid3″

Trackbacks/Pingbacks

  1. HowtoMatrix » Faster Internet - [...] Read more at Ubuntu Linux Help [...]
  2. Installing a Web Server - [...] a Web Developer / Designer PC Using Ubuntu Linux – Revisited Installing Compass on Ubuntu Faster Internet With an ...
  3. Ubuntu Linux Help - [...] One of my earlier posts, Faster Internet With an Old Laptop – Ubuntu and Squid, discussed how to install ...
  4. ubuntu squid proxy server error message - Admins Goodies - [...] The Way I got it working was to build it from scratch and instead of using the webmin deb ...

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>