# Local APT Repository Server ###### tags: `apt`, `repository` Two methods for local repository server. 1. Mirroring: a local APT repository server. 2. Caching: a local caching server for APT packages. VM Specification: ``` Uubntu 20.04 1 vCPU 2GB RAM 300GB data disk (/dev/vdb) Network IP 192.168.122.64 ``` The APT packages size are incresing from time to time, it is over 250GB when setup it in my environment on 2022-10-10. #### Steps to mirror apt repostory Install Apache Web Server ``` root@lab-apt-repository:~# apt install -y apache2; systemctl enable apache2 ``` Create package repository directory ``` root@lab-apt-repository:~# mkfs.ext4 /dev/vdb root@lab-apt-repository:~# mkdir /var/www/html/ubuntu root@lab-apt-repository:~# chown www-data:www-data /var/www/html/ubuntu/ root@lab-apt-repository:~# mount /dev/vdb /var/www/html/ubuntu/ ``` Install apt-mirror ``` root@lab-apt-repository:~# apt install -y apt-mirror ``` Configure repositories to mirror or sync ``` root@lab-apt-repository:~# apt install -y apt-mirror ``` ``` root@lab-apt-repository:~# sed -i 's/artful/focal/g' /etc/apt/mirror.list root@lab-apt-repository:~# sed -i 's/\/var\/spool\/apt-mirror/\/var\/www\/html\/ubuntu/g' /etc/apt/mirror.list ``` ``` root@lab-apt-repository:~# cat /etc/apt/mirror.list ############# config ################## # set base_path /var/www/html/ubuntu # # set mirror_path $base_path/mirror # set skel_path $base_path/skel # set var_path $base_path/var # set cleanscript $var_path/clean.sh # set defaultarch <running host architecture> # set postmirror_script $var_path/postmirror.sh # set run_postmirror 0 set nthreads 20 set _tilde 0 # ############# end config ############## deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu focal-proposed main restricted universe multiverse #deb http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu focal-security main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu focal-updates main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu focal-proposed main restricted universe multiverse #deb-src http://archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse clean http://archive.ubuntu.com/ubuntu ``` *__NOTE__*: Here I comment out the deb-src to skip mirroring source packages. Source packages are needed if you need to complile packages yourself or inspect source code. Copy postmirror script to the local repository directory ``` root@lab-apt-repository:~# mkdir -p /var/www/html/ubuntu/var root@lab-apt-repository:~# cp -afpR /var/spool/apt-mirror/var/postmirror.sh /var/www/html/ubuntu/var/ ``` Mirror the remote repositories to local repository directory ``` root@lab-apt-repository:~# apt-mirror Downloading 114 index files using 20 threads... Begin time: Sun Oct 9 15:49:52 2022 [20]... [19]... [18]... [17]... [16]... [15]... [14]... [13]... [12]... [11]... [10]... [9]... [8]... [7]... [6]... [5]... [4]... [3]... [2]... [1]... [0]... End time: Sun Oct 9 15:50:55 2022 Processing translation indexes: [TTT] Downloading 555 translation files using 20 threads... Begin time: Sun Oct 9 15:50:55 2022 output omit... ``` After mirroring, it consume 257GB (2022-10-10) ``` root@lab-apt-repository:~# df -h | grep vdb /dev/vdb 295G 257G 23G 92% /var/www/html/ubuntu ``` Create cnf script *cnf.sh* (Command Not Found, CNF) ``` #!/bin/bash for p in "${1:-focal}"{,-{security,updates}}/{main,restricted,universe,multiverse}; do >&2 echo "${p}" wget -q -c -r -np -R "index.html*" "http://archive.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-amd64.xz" wget -q -c -r -np -R "index.html*" "http://archive.ubuntu.com/ubuntu/dists/${p}/cnf/Commands-i386.xz" done ``` ``` root@lab-apt-repository:~# chmod +x ./cnf.sh root@lab-apt-repository:~# ./cnf.sh focal/main focal/restricted focal/universe focal/multiverse focal-security/main focal-security/restricted focal-security/universe focal-security/multiverse focal-updates/main focal-updates/restricted focal-updates/universe focal-updates/multiverse ``` ``` root@lab-apt-repository:~# cp -av ./archive.ubuntu.com /var/www/html/ubuntu/mirror/ './archive.ubuntu.com/ubuntu/dists/focal/main/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/main/cnf' './archive.ubuntu.com/ubuntu/dists/focal/main/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/main/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal/main/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/main/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf' './archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/restricted/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal/universe/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/universe/cnf' './archive.ubuntu.com/ubuntu/dists/focal/universe/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/universe/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal/universe/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/universe/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf' './archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal/multiverse/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf' './archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/main/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf' './archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/restricted/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf' './archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/universe/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf' './archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-security/multiverse/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf' './archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/main/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf' './archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/restricted/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf' './archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/universe/cnf/Commands-i386.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf' './archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf/Commands-amd64.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf/Commands-amd64.xz' './archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf/Commands-i386.xz' -> '/var/www/html/ubuntu/mirror/archive.ubuntu.com/ubuntu/dists/focal-updates/multiverse/cnf/Commands-i386.xz' ``` *__NOTE__*: This step is due to a bug https://bugs.launchpad.net/ubuntu/+source/debmirror/+bug/1821251 Allow http port 80 ``` root@lab-apt-repository:~# ufw allow 80 Rules updated Rules updated (v6) ``` Access local APT repository via web browser ![](https://i.imgur.com/ZiDpwTZ.png) Test local APT repository ``` root@lab-test:/etc/apt# cp ./sources.list sources.list.bak root@lab-test:/etc/apt# cat sources.list.bak | grep -v "^#" | grep deb | sed 's/au.archive.ubuntu.com/192.168.122.64\/ubuntu\/mirror\/archive.ubuntu.com/g' > ./sources.list root@lab-test:/etc/apt# sed -i '/focal-backports/s/^/#/' ./sources.list root@lab-test:/etc/apt# cat sources.list deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal main restricted deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-updates main restricted deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal universe deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-updates universe deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal multiverse deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-updates multiverse #deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-backports main restricted universe multiverse deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-security main restricted deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-security universe deb http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal-security multiverse ``` *__NOTE__*: comment out the "focal-backports" because it is not mirrored. ``` root@lab-test:/etc/apt# apt update root@lab-test:/etc/apt# apt list --upgradable Listing... Done isc-dhcp-client/focal-updates,focal-security 4.4.1-2.1ubuntu5.20.04.4 amd64 [upgradable from: 4.4.1-2.1ubuntu5.20.04.3] isc-dhcp-common/focal-updates,focal-security 4.4.1-2.1ubuntu5.20.04.4 amd64 [upgradable from: 4.4.1-2.1ubuntu5.20.04.3] linux-generic/focal-updates 5.4.0.128.129 amd64 [upgradable from: 5.4.0.126.127] linux-headers-generic/focal-updates 5.4.0.128.129 amd64 [upgradable from: 5.4.0.126.127] linux-image-generic/focal-updates 5.4.0.128.129 amd64 [upgradable from: 5.4.0.126.127] linux-libc-dev/focal-updates 5.4.0-128.144 amd64 [upgradable from: 5.4.0-126.142] ubuntu-advantage-tools/focal-updates 27.11.2~20.04.1 amd64 [upgradable from: 27.10.1~20.04.1] zlib1g/focal-updates 1:1.2.11.dfsg-2ubuntu1.4 amd64 [upgradable from: 1:1.2.11.dfsg-2ubuntu1.3] root@lab-test:/etc/apt# apt install python3-openstackclient Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: output omit... 0 upgraded, 68 newly installed, 0 to remove and 8 not upgraded. Need to get 13.1 MB of archives. After this operation, 76.2 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal/main amd64 python3-pyparsing all 2.4.6-1 [61.3 kB] Get:2 http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal/main amd64 python3-pyperclip all 1.7.0-1 [10.5 kB] Get:3 http://192.168.122.64/ubuntu/mirror/archive.ubuntu.com/ubuntu focal/main amd64 python3-wcwidth all 0.1.8+dfsg1-3 [17.4 kB] output omit... Setting up python3-cliff (3.1.0-0ubuntu1) ... Setting up python3-oslo.config (1:8.0.2-0ubuntu1) ... Setting up python3-keystoneclient (1:4.0.0-0ubuntu1) ... Setting up python3-osc-lib (2.0.0-0ubuntu1) ... Setting up python3-oslo.log (4.1.1-0ubuntu1) ... Setting up python3-openstackclient (5.2.0-0ubuntu1.20.04.1) ... root@lab-test:/etc/apt# openstack --version openstack 5.2.0 ``` #### set cront job to sync daily. For example ``` root@lab-apt-repository:~# crontab -e 00 01 * * * /usr/bin/apt-mirror >> /var/log/apt/apt-mirror.log ``` #### Troubleshooting apt-mirror fail with error ``` Failed to open Release file from http://archive.ubuntu.com/ubuntu/dists/artful/Release at /usr/bin/apt-mirror line 507 ``` ``` apt-mirror: can't open index archive.ubuntu.com/ubuntu//dists/artful/main/source/Sources in process_index at /usr/bin/apt-mirror line 800. ``` This is because the apt-mirror package version (0.5.4-1) was built with Artful (Ubuntu 17.10). ``` root@lab-apt-repository:~# apt install apt-mirror Reading package lists... Done Building dependency tree Reading state information... Done apt-mirror is already the newest version (0.5.4-1). ``` https://www.mail-archive.com/ubuntu-bugs@lists.ubuntu.com/msg5616342.html https://bugs.launchpad.net/ubuntu/+source/apt-mirror/0.5.4-1 update the /etc/apt/mirror.list ``` root@lab-apt-repository:~# sed -i 's/artful/focal/g' /etc/apt/mirror.list ``` #### APT Caching Server Install apt-cacher-ng ``` root@lab-apt-repository:~# apt install apt-cacher-ng -y ``` *__NOTE__*: select No when asked allow HTTP tunnels through Apt-Cacher NG. *__NOTE__*: keep default configuration (/etc/apt-cacher-ng/acng.conf) ``` root@lab-apt-repository:~# systemctl status apt-cacher-ng ● apt-cacher-ng.service - Apt-Cacher NG software download proxy Loaded: loaded (/lib/systemd/system/apt-cacher-ng.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2022-10-13 00:32:46 AEDT; 2min 11s ago Main PID: 29460 (apt-cacher-ng) Tasks: 1 (limit: 2273) Memory: 2.0M CGroup: /system.slice/apt-cacher-ng.service └─29460 /usr/sbin/apt-cacher-ng -c /etc/apt-cacher-ng ForeGround=1 Oct 13 00:32:46 lab-apt-repository systemd[1]: Starting Apt-Cacher NG software download proxy... Oct 13 00:32:46 lab-apt-repository systemd[1]: Started Apt-Cacher NG software download proxy. ``` ``` root@lab-apt-repository:~# systemctl enable apt-cacher-ng Synchronizing state of apt-cacher-ng.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable apt-cacher-ng ``` The cacher server is listening port 3142 ``` root@lab-apt-repository:~# netstat -antp | grep LISTEN tcp 0 0 0.0.0.0:3142 0.0.0.0:* LISTEN 29460/apt-cacher-ng tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4415/apache2 tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 571/systemd-resolve tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 636/sshd: /usr/sbin tcp6 0 0 :::3142 :::* LISTEN 29460/apt-cacher-ng tcp6 0 0 :::22 :::* LISTEN 636/sshd: /usr/sbin ``` This is path which store cached packages ``` root@lab-apt-repository:~# tree /var/cache/apt-cacher-ng/ /var/cache/apt-cacher-ng/ └── _xstore ├── qstats │   ├── i │   └── o └── rsnap 5 directories, 0 files ``` Verify the APT Cache Server *http://192.168.122.64:3142/acng-report.html* ![](https://i.imgur.com/ZRnxNvT.png) To test APT caching server, create apt proxy configuration file */etc/apt/apt.conf.d/00aptproxy* on a Ubuntu client. ``` root@lab-test:/etc/apt/apt.conf.d# cat 00aptproxy Acquire::http::Proxy "http://192.168.122.64:3142"; ``` Install nginx on the client. ``` root@lab-test:/etc/apt/apt.conf.d# apt install nginx -y ``` Check APT Cache Server ``` root@lab-apt-repository:~# tree /var/cache/apt-cacher-ng/ /var/cache/apt-cacher-ng/ ├── 192.168.122.64 │   └── ubuntu │   └── mirror │   └── archive.ubuntu.com │   └── ubuntu │   └── pool │   └── main │   ├── f │   │   ├── fontconfig │   │   │   ├── fontconfig-config_2.13.1-2ubuntu3_all.deb │   │   │   ├── fontconfig-config_2.13.1-2ubuntu3_all.deb.head │   │   │   ├── libfontconfig1_2.13.1-2ubuntu3_amd64.deb │   │   │   └── libfontconfig1_2.13.1-2ubuntu3_amd64.deb.head │   │   └── fonts-dejavu │   │   ├── fonts-dejavu-core_2.37-1_all.deb │   │   └── fonts-dejavu-core_2.37-1_all.deb.head │   ├── libg │   │   └── libgd2 │   │   ├── libgd3_2.2.5-5.2ubuntu2.1_amd64.deb │   │   └── libgd3_2.2.5-5.2ubuntu2.1_amd64.deb.head │   ├── libx │   │   └── libxpm │   │   ├── libxpm4_3.5.12-1_amd64.deb │   │   └── libxpm4_3.5.12-1_amd64.deb.head │   └── n │   └── nginx │   ├── libnginx-mod-http-image-filter_1.18.0-0ubuntu1.3_amd64.deb │   ├── libnginx-mod-http-image-filter_1.18.0-0ubuntu1.3_amd64.deb.head │   ├── libnginx-mod-http-xslt-filter_1.18.0-0ubuntu1.3_amd64.deb │   ├── libnginx-mod-http-xslt-filter_1.18.0-0ubuntu1.3_amd64.deb.head │   ├── libnginx-mod-mail_1.18.0-0ubuntu1.3_amd64.deb │   ├── libnginx-mod-mail_1.18.0-0ubuntu1.3_amd64.deb.head │   ├── libnginx-mod-stream_1.18.0-0ubuntu1.3_amd64.deb │   ├── libnginx-mod-stream_1.18.0-0ubuntu1.3_amd64.deb.head │   ├── nginx_1.18.0-0ubuntu1.3_all.deb │   ├── nginx_1.18.0-0ubuntu1.3_all.deb.head │   ├── nginx-common_1.18.0-0ubuntu1.3_all.deb │   ├── nginx-common_1.18.0-0ubuntu1.3_all.deb.head │   ├── nginx-core_1.18.0-0ubuntu1.3_amd64.deb │   └── nginx-core_1.18.0-0ubuntu1.3_amd64.deb.head └── _xstore ├── qstats │   ├── i │   └── o └── rsnap ``` *__NOTE__*: To clean cache ``` $ systemctl apt-cacher-ng stop $ rm -rf /var/cache/apt-cacher-ng/ $ systemctl apt-cacher-ng start ``` Or via the web UI ![](https://i.imgur.com/NmePj3R.png) *__NOTE__*: Set Access Control to the cache server, for example: Deny specifc hosts and subnet, */etc/hosts.deny* ``` apt-cacher-ng: 192.168.122.10 192.168.122.11 192.168.122.12 ``` Block all local traffic from 192.168.122.0/24 except 192.168.122.10 In */etc/hosts.allow* ``` apt-cacher-ng: 192.168.122.10 ``` In */etc/hosts.deny* ``` apt-cacher-ng: 192.168.122.0/24 ``` #### Reference Ubuntu 20.04 - https://www.linuxtechi.com/setup-local-apt-repository-server-ubuntu/ - https://sandeeprao.net/setup-ubuntu-20-04-repository-mirror-server/ - https://bugs.launchpad.net/ubuntu/+source/debmirror/+bug/1821251 - https://www.xmodulo.com/apt-caching-server-ubuntu-debian.html CentOS - https://www.server-world.info/en/note?os=CentOS_Stream_9&p=localrepo