How to Set Up a Local Update Server for Ubuntu Desktops
Maintaining multiple Ubuntu desktops in an office, school, or lab environment can become bandwidth-intensive if each machine downloads updates from the internet individually. A more efficient solution is to set up a local update server, which caches packages and distributes them to all local machines.
In this guide, we walk through how to set up a local Ubuntu package mirror using apt-cacher-ng
, a lightweight and efficient caching proxy for Debian-based systems.
🧰 Prerequisites
- A dedicated Ubuntu server (or one of your desktops) that will act as the cache server.
- Internet access on the server.
- Static IP or reserved DHCP IP for the cache server.
- Ubuntu desktops configured to use the cache.
🖥️ Step 1: Install apt-cacher-ng
on the Server
sudo apt update
sudo apt install apt-cacher-ng
Once installed, the service starts automatically. You can check its status with:
sudo systemctl status apt-cacher-ng
⚙️ Step 2: Configure apt-cacher-ng
(Optional)
The default settings are usually fine for most use cases. But if you want to review or tweak the settings:
sudo nano /etc/apt-cacher-ng/acng.conf
Ensure this line is set (it usually is):
PassThroughPattern: .*ubuntu.com/.*
To allow web access to the stats page, find and set:
ReportPage: acng-report.html
Then restart the service:
sudo systemctl restart apt-cacher-ng
🌐 Step 3: Allow Access Through Firewall (If Enabled)
If UFW is enabled:
sudo ufw allow 3142/tcp
Port 3142 is the default port used by apt-cacher-ng
.
🧪 Step 4: Test the Server Locally
You can test the server by accessing this URL in a browser on another machine:
http://<cache-server-ip>:3142/acng-report.html
You should see the Apt-Cacher NG status page.
🧑💻 Step 5: Configure Ubuntu Clients
On each Ubuntu desktop, edit or create the file:
sudo nano /etc/apt/apt.conf.d/01proxy
Add this line (replace <cache-server-ip>
with your server’s IP address):
Acquire::http::Proxy "http://<cache-server-ip>:3142";
Example:
Acquire::http::Proxy "http://192.168.1.10:3142";
Now, whenever you run:
sudo apt update && sudo apt upgrade
The desktop will fetch packages from your local cache server, downloading from the internet only if they’re not already cached.
🧹 Optional: Exclude Certain Packages or Repositories
You can fine-tune what gets cached in /etc/apt-cacher-ng/acng.conf
. Look for directives like:
ExThreshold: 10
Or define blacklist patterns. See the man page for more advanced options:
man acng.conf
📊 Monitor Usage
Check the cache statistics and logs via:
- Web UI:
http://<cache-server-ip>:3142/acng-report.html
- Log file:
/var/log/apt-cacher-ng/apt-cacher.log
✅ Final Tips
- Regularly monitor disk space. Cache can grow over time.
- Use
cron
orlogrotate
to manage logs and old cached files. - Works seamlessly for Ubuntu, Debian, and derivatives (Linux Mint, Pop!_OS).
Setting up a local update server is a smart move for environments with multiple machines. It reduces internet usage, speeds up updates, and improves reliability during high-traffic times. Once configured, it’s mostly maintenance-free.
Post Comment