Software & AppsOperating SystemLinux

How To Cache Apt Downloads on a LAN for Faster Updates

Ubuntu 12

In a LAN environment, especially where multiple systems use the same Linux distribution, it’s common to download the same packages multiple times. This can be a waste of bandwidth and time. To optimize this, you can cache apt downloads on a LAN for faster updates. This article will guide you through the process using two popular solutions: squid-deb-proxy and apt-cacher-ng.

Quick Answer

Caching apt downloads on a LAN for faster updates is possible by using solutions like squid-deb-proxy or apt-cacher-ng. These caching proxies allow multiple systems in a LAN environment to download packages only once, saving bandwidth and time.

Squid-Deb-Proxy

Server Configuration

Firstly, you need a machine to act as the server. On this machine, install squid-deb-proxy and avahi-utils with the following command:

sudo apt-get install squid-deb-proxy avahi-utils

Here, squid-deb-proxy is the package that provides the caching services, while avahi-utils allows for zero configuration networking.

Once installed, start the squid-deb-proxy service:

sudo systemctl start squid-deb-proxy

If your server has a firewall enabled, you may need to allow connections to the proxy server.

Client Configuration

On the client machines, install squid-deb-proxy-client:

sudo apt-get install squid-deb-proxy-client

This package automatically discovers the proxy on your network and configures apt to use it.

Benefits of Squid-Deb-Proxy

The squid-deb-proxy is easy to set up and provides zero configuration on clients. It also supports caching third-party sources, which can be beneficial if you use software from PPAs.

Apt-Cacher-NG

Server Configuration

On the server machine, install apt-cacher-ng:

sudo apt-get install apt-cacher-ng

apt-cacher-ng is a caching proxy specialized for package files from Linux distributors.

Once installed, you can access the apt-cacher-ng report page by navigating to http://your-server-ip:3142/acng-report.html.

Client Configuration

On the client machines, you need to tell apt to use the apt-cacher-ng server as a proxy. This can be done by creating a file named 01proxy in /etc/apt/apt.conf.d/ with the following content:

Acquire::http::Proxy "http://your-server-ip:3142";

Replace your-server-ip with the IP address of your server.

Benefits of Apt-Cacher-NG

apt-cacher-ng is a simple and effective solution for small environments. It supports caching packages from different sources and system versions, which can be beneficial if you have a mixed environment.

Conclusion

Caching apt downloads on a LAN can significantly speed up updates and installations, saving bandwidth and time. Whether you choose squid-deb-proxy or apt-cacher-ng depends on your specific requirements and preferences. Both solutions are effective and have their own advantages. With this guide, you should be able to set up either solution and start benefiting from cached apt downloads.

What is the purpose of caching apt downloads on a LAN?

Caching apt downloads on a LAN helps to optimize bandwidth and save time by avoiding multiple downloads of the same packages. It allows systems within the LAN to retrieve packages from a local cache instead of downloading them from the internet.

How does `squid-deb-proxy` work?

squid-deb-proxy acts as a caching proxy server for apt packages. When a client requests a package, squid-deb-proxy checks if it already has a cached copy. If it does, it serves the package from the cache. If not, it downloads the package and caches it for future use.

What is zero configuration networking?

Zero configuration networking, also known as zeroconf or automatic networking, is a set of protocols that allows devices on a LAN to automatically discover and connect to each other without manual configuration. In the context of caching apt downloads, zero configuration networking enables clients to automatically discover the proxy server without the need for manual configuration.

Can `squid-deb-proxy` cache packages from third-party sources?

Yes, squid-deb-proxy supports caching packages from third-party sources, including software from PPAs (Personal Package Archives). This can be useful if you use software from external sources and want to reduce the download time for those packages.

How does `apt-cacher-ng` differ from `squid-deb-proxy`?

apt-cacher-ng is a caching proxy specialized for package files from Linux distributors, while squid-deb-proxy is a more general caching proxy for apt packages. apt-cacher-ng offers more advanced features, such as support for caching packages from different sources and system versions, making it suitable for mixed environments.

Can `apt-cacher-ng` be accessed through a web interface?

Yes, apt-cacher-ng provides a web interface that can be accessed by navigating to http://your-server-ip:3142/acng-report.html in a web browser. This interface allows you to view various reports and statistics related to the cached packages.

Is it possible to use both `squid-deb-proxy` and `apt-cacher-ng` simultaneously on a LAN?

Yes, it is possible to use both squid-deb-proxy and apt-cacher-ng simultaneously on a LAN. However, it is recommended to choose one solution for caching apt downloads to avoid conflicts and ensure proper functionality.

Leave a Comment

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