stop apt looking for srv records

I am trying to use apt on a network that is only intermittently connected to the Internet. The network has a local apt mirror and I have put the ip address of that mirror in all the entries in sources.list.

Unfortunately when disconnected from the Internet there is an annoying delay in running apt commands. Investigating with tcpdump shows.

14:44:52.271437 IP 172.19.0.2.42208 > 8.8.8.8.domain: 180+ SRV? _http._tcp.172.19.0.1. (39)
14:44:57.277063 IP 172.19.0.2.42208 > 8.8.8.8.domain: 180+ SRV? _http._tcp.172.19.0.1. (39)
14:44:57.277160 IP 172.19.0.1 > 172.19.0.2: ICMP net 8.8.8.8 unreachable, length 75
14:45:02.286414 IP 172.19.0.2.42208 > 8.8.8.8.domain: 180+ SRV? _http._tcp.172.19.0.1. (39)
14:45:02.286504 IP 172.19.0.1 > 172.19.0.2: ICMP net 8.8.8.8 unreachable, length 75

Is there any way to stop apt doing this and just make it connect immediately to the local mirror?

Asked By: plugwash

||

Try putting the apt mirror in as the apt proxy.

Create the file if it does not exist:
/etc/apt/apt.conf

Add the apt proxy info:

Acquire::http::Proxy "http://address:port";

or in your case:

Acquire::http::Proxy "http://172.19.0.2.42208";

Don’t forget the ; at the end.

Test by updating:

sudo apt-get update

I am not sure if your mirror will work this way. Perhaps an apt cacher like apt-cacher-ng will help.

If you have a full mirror couldn’t you change the domain name part of the source to your mirror ip address?

Example if the source was:

deb http://ftp.ussg.iu.edu/linux/ubuntu xenial main restricted universe multiverse

Change to:

deb http://172.19.0.2.42208/linux/ubuntu xenial main restricted universe multiverse

Answered By: jc__

Ok I found the answer by reading the sourcecode

Add the following to /etc/apt/apt.conf (create it if it doesn’t exist)

Acquire::EnableSrvRecords "false";
Answered By: plugwash
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.