É altamente improvável que as variáveis de ambiente listadas possam afetar apt-get
. No entanto, a saída de host
não é um indicador confiável de que a resolução de nomes de host está funcionando.
Considere:
$ grep hosts /etc/nsswitch.conf
hosts: files
$ host google.com
google.com has address 172.217.26.14
google.com has IPv6 address 2404:6800:4004:809::200e
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
$ sudo apt update
Err:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Could not resolve 'security.ubuntu.com'
Err:2 http://jp.archive.ubuntu.com/ubuntu xenial InRelease
Could not resolve 'jp.archive.ubuntu.com'
Err:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease
Could not resolve 'jp.archive.ubuntu.com'
Err:4 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease
Could not resolve 'jp.archive.ubuntu.com'
Err:5 http://archive.canonical.com/ubuntu xenial InRelease
Could not resolve 'archive.canonical.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
12 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://jp.archive.ubuntu.com/ubuntu/dists/xenial/InRelease Could not resolve 'jp.archive.ubuntu.com'
W: Failed to fetch http://jp.archive.ubuntu.com/ubuntu/dists/xenial-updates/InRelease Could not resolve 'jp.archive.ubuntu.com'
W: Failed to fetch http://jp.archive.ubuntu.com/ubuntu/dists/xenial-backports/InRelease Could not resolve 'jp.archive.ubuntu.com'
W: Failed to fetch http://archive.canonical.com/ubuntu/dists/xenial/InRelease Could not resolve 'archive.canonical.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease Could not resolve 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.
apt-get
, e a maioria dos aplicativos, usam gethostbyname(3)
da glibc para a resolução do nome do host, que é adiada para /etc/nsswitch.conf
para decidir quais métodos usar para isso. Se nsswitch.conf
estiver configurado incorretamente, host
(e nslookup
, dig
, etc.) funcionará corretamente, mas a maioria dos aplicativos falhará na resolução do nome do host.
Essa é uma causa possível.