!!! Mediawiki has been upgraded !!!
Slack integration has been disabled for now due to an incompatibility.
If you want to testdrive the new skin (Tweeki), make sure your language settings are set to 'en - English' in your preferences!

Apt cache server

From Brixel - Hackerspace Hasselt
Jump to: navigation, search

Project: Apt Cache Server
Description: Building an Apt Caching Server for Brixel
Status: Completed
Participants: Woutervddn
Expertise: Linux, Network, Proxy
Edit tags: Apt cache server

Brixel Uses the Wireless Belgium Network. This means that we don't have to pay for our bandwidth usage. There is however a fair use policy, and network speeds get's degraded pretty quickly when you've got multiple visitors using our internet connection.

Apart from personal devices, we've currently got 3 desktop computers connected to the network, and 3 other computers that will be connected pretty soon. When I started the computer at the bar, I noticed that the updates would take about 140MB. It was about 2 weeks since the last time I upgraded them, so it isn't that unthinkable that we'll be having 500MB updates when we forget to update for a couple of weeks. (Even my personal Ubuntu Laptop has this sometimes)

140MB x 3 desktops (= 420MB) isn't that bad, but 500MB x 6 desktops (= 3GB) isn't that trivial anymore. It can take quite a while on our connection when others are also using the network, and it doesn't make sense to download those packages more than once.

How Updates Work

In all Debian based Linux distro's like Ubuntu, Linux Mint, ElementaryOS,... the "APT" system is used to update and install packages. A package is typically stored in a .deb file. Executing the .deb file will install the program.

All the most used .deb files are combined in a couple of "Repositories". A Repository houses all relevant packages for that Repo. There is a security repo for security updats, a repo with programs maintained by Linux Mint, one with most other Packages and one for closed source packages.

Via the commandline (might not be the most user friendly way, but still the fastest) you can perform an:

  • "apt-get update" command to update your available-package-list
  • And use "apt-get install PROGRAMNAME" to install the package you want.
  • To update your package you can use the "apt-get upgrade" command. All your packages that have updates will be automatically updated now.

The Solution To Our Problem


Turns out that there is a program called "apt-cacher-ng" that does everything you need. When you install this program it sets up a proxy server that only handles packages.

Whenever a computer uses the apt-cacher-ng proxy to get a package, it will check "do I already have this package stored locally?". If so, apt-cacher-ng will forward this package to the requesting computer instead of downloading the package again. If the package isn't stored locally already, it will download the package and store it on the computer where apt-cacher-ng is active.

How To Configure

Configuration was surprisingly easy, just add an apt-get proxy to ALL computers (that means also the computer where you installed apt-cacher-ng on)

On Host

On the Host that has "apt-cacher-ng" running, you edit the following file as root: /etc/apt/apt.conf.d/80proxy if it doesn't exist yet (by default it doesn't) you can make it.

And add the following line to it: Acquire::http { Proxy "http://localhost:3142"; };

On Clients

On all other computers running the same OS, you can add the following to /etc/apt/apt.conf.d/80proxy :

Acquire::http { Proxy "http://HOSTIP:3142"; };

Where HOSTIP equals the local IP address from your host computer running "apt-cacher-ng".

You can find the IP address from your host by typing the following command in the terminal of the host machine:


Next to your connection (probably eth0) you will see "inet addr:" followed by an IP address. (Like "inet addr:") Use this IP address as HOSTIP

Can I only use this on Mint

No you can also use this on all other debian based distro's. I'm not sure, but I believe you can even use apt-cacher-ng on a Linux Mint host to update your Ubuntu, Debian or Elementary installation. It doens't matter as long as it's apt based. (Although he might redownload the package for every first time a NEW distro tries to get it)

1 Quick install that will save us a ton of bandwidth in the future.

Pease Out!