From the server you can announce to the network there is an apt-cacher-ng instance through avahi
From the client you can check if exist an apt-cacher-ng service and modify apt proxy settings accordly.
Server
Install
$ sudo apt-get install apt-cacher-ng squid-deb-proxy-client
For Ubuntu releases older than 14.04 put the following snippet in /etc/avahi/services/apt-cacher-ng.service:
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">apt-cacher-ng proxy on %h</name>
<service protocol="ipv4">
<type>_apt_proxy._tcp</type>
<port>3142</port>
</service>
</service-group>
Client
Install
$ sudo apt-get install squid-deb-proxy-client
Here is a snippet to install server|client depending if there is already an apt-get proxy or not:
Source: http://blog.surgut.co.uk/2013/03/avahi-apt-cacher-ng-sbuild.html
/etc/apt/apt.conf.d/30autoproxy
, which contains the single line:Acquire::http::ProxyAutoDetect "/usr/share/squid-deb-proxy-client/apt-avahi-discover";
(referring to a Python script). Sweet. This gets installed bysquid-deb-proxy-client
. So for my own scenario I don't need that on the server at all! – 0xC0000022L Apr 29 '20 at 21:21