Skip to content

Saving Bandwidth With Apt-Cacher : Revisited

Those of you that are long time readers may remember my previous article on Saving Bandwidth With Multiple Machines Using Apt-Cacher. With the next Ubuntu release coming down the pike in just a few weeks I wanted to revisit this article for those of you that will be upgrading via aptitude. If you have multiple machines you’ll really want to look into setting this up!

I’ve been testing and retesting different hardware running Ubuntu 7.10 alpha and now beta releases. Nothing is worse than installing two machines and downloading the same updates twice, one for each machine. Apt-Cacher steps in at this point and lets us just download the update once to then be shared by all. Let’s revisit the setup:

Installing Apt-Cacher

The first thing you’ll need to do is select a central machine that you’ll want to act as your apt-caching service. I use one of my old servers sitting in the closet, but this could be one of your desktops if you like. You should note that this machine will need to be on any time another networked machine wants to request an update. On this single machine we’ll install the apt-caching service:

sudo aptitude install apt-cacher

Configure Apt-Cacher

You’ll also want to set this service to auto start at boot time. To do this make the following change:

sudo vim /etc/default/apt-cacher

change AUTOSTART=0 to AUTOSTART=1

You’ll also want to updated the access restrictions to allow your local machines access to this service. By default only localhost (127.0.0.1) will be allowed.

sudo vim /etc/apt-cacher/apt-cacher.conf

change allowed_hosts=127.0.0.1 to allowed_hosts=192.168.0.0/24 (update to your range as appropriate)

Once you’ve made these changes you’ll need to restart the apt-cacher service on the central machine:

sudo /etc/init.d/apt-cacher restart

Configure the Clients

You can configure your client machines (the other machines on your network) to use this apt-caching system with a simple edit to the apt sources.list file. Make sure you know the IP address of the apt-caching server you configured above.

If your sources.list currently looks something like this:

deb http://archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse

prefix the address to include the caching-server IP address: (replace 192.168.0.3 with your local server IP)

deb http://192.168.0.3:3142/archive.ubuntu.com/ubuntu/ gutsy main restricted universe multiverse
deb http://192.168.0.3:3142/archive.ubuntu.com/ubuntu/ gutsy-updates main restricted universe multiverse
deb http://192.168.0.3:3142/security.ubuntu.com/ubuntu/ gutsy-security main restricted universe multiverse

Once you’ve done this to the clients you should be able to fetch and install updates via the central machine and save bandwidth. Once a package has been fetched for one machine it will stay available centrally for each of the others therefore saving bandwidth and increasing update times by using LAN speeds vs WAN speeds.

If you’re interested in more information see my previous post on the topic or see the man page for apt-cacher (man apt-cacher).

If this site has been useful, please consider participating in the Fundraiser.

Other Points of Interest

  • No Related Post