Setting Up a Debian 10 Package Cache Server with Apt-Cacher-NG

Chưa phân loại
In this article, I am going to show you how to set up a Debian 10 package cache server with Apt-Cacher-NG to save bandwidth and increase package download speed. It is one of the best solution for local network where a lot of Debian 10 machines are running. So, let’s get started.

Configuring Static IP on the Server:

You should configure a static IP address on the server where you want to configure Apt-Cacher-NG.

You can find the current IP address of your Debian 10 server with the following command:

$ ip a

As you can see, the IP address in my case is I want to assign a static IP to this server, which is on the same network as before. Notice the network interface device name is ens33 in my case. It will be different for you. So, replace it with yours from now on.

Now, open the /etc/network/interfaces file with nano text editor with the following command:

$ sudo nano /etc/network/interfaces

Now, remove the marked line if present in the /etc/network/interfaces file.

Once you removed the lines, add the following lines to the /etc/network/interfaces file.

allow-hotplug ens33
iface ens33 inet static

NOTE: Change the device name, IP address, gateway and DNS name server address depending on your network and configuration requirement.

The final configuration file should look as follows. Now, save the file by pressing <Ctrl> + X followed by Y and <Enter>.

Now, reboot the server with the following command:

$ sudo reboot

Once your server boots, run the following command to verify that the IP address has changed.

$ ip a

As you can see, the IP address is set.

As you can see, internet connectivity also works. So, we are good.

$ ping -c 3

Installing Apt-Cacher-NG on the Server:

Apt-Cacher-NG is available in the official Debian 10 package repository. So, you can easily install it with the APT package manager.

First, update the APT package repository cache with the following command:

$ sudo apt update

The APT package repository cache should be updated.

Now, run the following command to install Apt-Cacher-NG:

$ sudo apt install apt-cacher-ng

Once you see the following prompt, select <No> and press <Enter> to continue.

Apt-Cacher-NG should be installed.

Now, check whether Apt-Cache-NG is running using the following command:

$ sudo systemctl status apt-cacher-ng

As you can see, apt-cacher-ng service is active/running. It is also enabled, which means it’s added to the system startup by default. So, it will start automatically on system boot.

NOTE: If for any case, apt-cacher-ng service is not running or is disabled (not added in the system startup), then run the following commands to start apt-cacher-ng and add it to the system startup.

$ sudo systemctl start apt-cacher-ng
$ sudo systemctl enable apt-cacher-ng

Configuring Debian 10 Machines with Proxy:

Now, to configure your Debian 10 servers and clients on the network, you have to tell APT to use the Apt-Cacher-NG HTTP Proxy. Once you do, all the packages the clients and servers that use the proxy downloads will be cached on the Apt-Cacher-NG server. Thus, download speed, bandwidth usage and delay will be reduced significantly.

To configure a Debian 10 machine to use the Apt-Cacher-NG proxy, create a new file 02proxy in the /etc/apt/apt.conf.d/ directory with the following command:

$ sudo nano /etc/apt/apt.conf.d/02proxy

Now, type in the following line to the 02proxy file.

Acquire::http::Proxy "";

NOTE: Don’t forget to replace the IP address with the IP address of your own Apt-Cacher-NG server.

The final configuration file should look as follows. Now, save the file by pressing <Ctrl> + X followed by Y and <Enter>.

Your Debian 10 machine should now use the Apt-Cacher-NG proxy to download packages and Apt-Cacher-NG server should cache all the packages.

Apt-Cacher-NG Statistics Report:

From any computer on the network, if you visit the page, it will display statistics information about the Apt-Cacher-NG.

If you visit the acng-report.html page for the first time, it will be not show any statistic data. So, you have to click on Count Data button for the first time.

Once you do, it will show you how much data is downloaded from the internet, how much data is server from the cache. Also, the HTTP request hits (cached) and misses (not cached).

I configured the proxy and installed some packages on some of the Debian 10 machines on my network. As you can see, data downloaded is less than data served. Again, there are a lot of hits requests. So, cache is working correctly.

I downloaded nodejs and npm packages on 2 Debian 10 minimal servers. One with cache enabled and one without cache.

Without cache, it took about 1 min and 39 seconds = 99 seconds to complete the download of all the required packages.

With cache enabled, it took only 1s to download all the required packages as you can see in the screenshot below.

Configuring Apt-Cacher-NG:

The configuration directory of Apt-Cacher-NG is /etc/apt-cacher-ng/

The important configuration files are acng.conf, backends_debian in our case.

$ ls /etc/apt-cacher-ng/

You can open the backends_debian configuration file as follows:

$ sudo nano /etc/apt-cacher-ng/backends_debian

In this file, the Debian 10 HTTP repositories to be cached are placed. Right now, I am caching packages downloaded from If you’re using some other Debian 10 repositories, then add them here.

You can open the acng.conf file with the following command:

$ sudo nano /etc/apt-cacher-ng/acng.conf

This file is very long and has a lot of configuration options. But, the most important option is CacheDir. If you want to change the directory where cached packages are stored, change the CacheDir.

If you change the CacheDir to a new directory, then change the user and group of the new directory to apt-cacher-ng as follows:

$ sudo chown -Rfv apt-cacher-ng:apt-cacher-ng

If you change Apt-Cacher-NG configuration file, then don’t forget to restart the apt-cacher-ng service with the following command:

$ sudo systemctl restart apt-cacher-ng

So, that’s how you set up a Debian 10 package cache server with Apt-Cacher-NG. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Best Laptops for Arch Linux

(This post contains affiliate links. It is a way for this site to earn advertising fees by advertising or linking to certain...

HITMAN Now Available For Linux – The Complete First Season

Feral Interactive recently released HITMAN: The Complete First Season for Linux. Hitman is an episodic stealth video game...

Best Video Downloaders for Firefox

Top 10 Video Downloaders for Firefox Even if there are many online media streaming websites like YouTube and DailyMotion...
Bài Viết

Bài Viết Mới Cập Nhật


Mua Proxy v6 US Private chạy PRE, Face, Insta, Gmail

Mua shadowsocks và hướng dẫn sữ dụng trên window

Tại sao Proxy Socks lại được ưa chuộng hơn Proxy HTTP?

Mua thuê proxy v4 nuôi zalo chất lượng cao, kinh nghiệm tránh quét tài khoản zalo