[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

apt ignoring nsswitch.conf order for host names resolution



Hello all,

+++ Problem:

apt is always querying the dns server for name resolution when doing "apt-get update" regardless of the content of /etc/nsswitch.conf. The dns server is not connected to internet and this is causing the apt to wait ~20 seconds for dns to timeout. This should not happen, becuase the apt repository host (bootserv) is defined in /etc/hosts.

+++ Software:

$ uname -a
Linux p1entry1 4.9.51-4.0.46-ape #1 SMP Mon Jan 29 09:48:44 UTC 2018 i686 GNU/Linux

$ cat /etc/debian_version
9.3

$ dpkg -l | grep apt

ii apt 1.4.8 i386 commandline package manager ii apt-utils 1.4.8 i386 package management related utility programs ii libapt-inst2.0:i386 1.4.8 i386 deb package format runtime library ii libapt-pkg5.0:i386 1.4.8 i386 package management runtime library


+++ Configuration:

$ cat /etc/nsswitch.conf

passwd:         compat
group:          compat
shadow:         compat
gshadow:        files

hosts:          files dns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis


$ cat /etc/hosts

127.0.0.1 localhost
192.168.68.60 xp342.amano.ca xp342
192.168.68.60 bootserv.amano.ca bootserv
192.168.68.60 xparcserv.amano.ca xparcserv


$ cat /etc/resolv.conf

search amano.ca
nameserver 192.168.68.60

$ cat /etc/apt/sources.list.d/*.list
deb [trusted=yes] http://bootserv/repo/amano/debian stretch main non-free
deb [trusted=yes] http://bootserv/repo/amano/debian xparc-stable non-free
deb [trusted=yes] http://bootserv/repo/amano/debian xparc-generated-stable non-free


+++ Tests:
1) with the above /etc/resolv.conf contents
$ time sudo apt-get update
0% [Working]
Ign:1 http://bootserv/repo/amano/debian stretch InRelease
Ign:2 http://bootserv/repo/amano/debian xparc-stable InRelease
Ign:3 http://bootserv/repo/amano/debian xparc-generated-stable InRelease
Hit:4 http://bootserv/repo/amano/debian stretch Release
Hit:5 http://bootserv/repo/amano/debian xparc-stable Release
Hit:6 http://bootserv/repo/amano/debian xparc-generated-stable Release
Ign:7 http://bootserv/repo/amano/debian stretch Release.gpg
Ign:8 http://bootserv/repo/amano/debian xparc-stable Release.gpg
Ign:9 http://bootserv/repo/amano/debian xparc-generated-stable Release.gpg
Reading package lists... Done
W: Conflicting distribution: http://bootserv/repo/amano/debian stretch Release (expected stretch but got stretch-4.0.0.78) W: Conflicting distribution: http://bootserv/repo/amano/debian xparc-stable Release (expected xparc-stable but got xparc-4.0.0.78)

real	0m20.121s
user	0m0.072s
sys	0m0.020s

2) with contents of /etc/resolv.conf commented
$ time sudo apt-get update
Ign:1 http://bootserv/repo/amano/debian stretch InRelease
Ign:2 http://bootserv/repo/amano/debian xparc-stable InRelease
Ign:3 http://bootserv/repo/amano/debian xparc-generated-stable InRelease
Hit:4 http://bootserv/repo/amano/debian stretch Release
Hit:5 http://bootserv/repo/amano/debian xparc-stable Release
Hit:6 http://bootserv/repo/amano/debian xparc-generated-stable Release
Ign:7 http://bootserv/repo/amano/debian stretch Release.gpg
Ign:8 http://bootserv/repo/amano/debian xparc-stable Release.gpg
Ign:9 http://bootserv/repo/amano/debian xparc-generated-stable Release.gpg
Reading package lists... Done
W: Conflicting distribution: http://bootserv/repo/amano/debian stretch Release (expected stretch but got stretch-4.0.0.78) W: Conflicting distribution: http://bootserv/repo/amano/debian xparc-stable Release (expected xparc-stable but got xparc-4.0.0.78)

real	0m0.115s
user	0m0.068s
sys	0m0.016s


+++ Observation:
1) libc resolver works correctly (the "bootserv" name is correctly resolved using /etc/hosts):
$ getent hosts bootserv
192.168.68.60  bootserv.amano.ca bootserv

2) "strace apt-get update" always shows network connect call to dns, regardless of /etc/nsswitch.conf settings.

Any idea what is causing this behaviour?
Thanks

--
Bogdan Veringioiu

Amano Parking Europe N.V.
Uersfeld 24
52072 Aachen, Germany

e-mail:   bogdan.veringioiu@amano.eu
web:      www.amano.eu


Reply to: