Ipv6 is disabled globally: Kernel -> # CONFIG_IPV6 is not set USE flags -> -ipv6 hostname -f triggers a query to the dns: 02-Sep-2014 19:27:43.407 queries: info: client 127.0.0.1#52072 (vx-marco.intranet.test.it): query: vx-marco.intranet.test.it IN AAAA + (127.0.0.1) 02-Sep-2014 19:27:43.408 queries: info: client 127.0.0.1#40075 (vx-marco): query: vx-marco IN AAAA + (127.0.0.1) These are the questions: - Why hostname -f trigger a dns query if configuration in nsswitch.conf and host.conf prefer files ? - why ipv6 query AAAA and not ipv4 if it has to ? - due to this dns query there is a short delay executing hostname -f , is it safe to put the hostname and hostname FQDN in /etc/hosts like 127.0.0.2 vx-marco.intranet.test.it vx-marco here some config files: cat /etc/hosts 127.0.0.1 vx-beta.intranet.test.it vx-beta localhost cat /etc/resolv.conf domain intranet.test.it nameserver 127.0.0.1 cat /etc/host.conf order hosts, bind multi on cat /etc/nsswitch.conf passwd: compat shadow: compat group: compat # passwd: db files nis # shadow: db files nis # group: db files nis hosts: files dns networks: files dns services: db files protocols: db files rpc: db files ethers: db files netmasks: files netgroup: files bootparams: files automount: files aliases: files Reproducible: Always Steps to Reproduce: 1.Listen to dns log 2.hostname -f 3. Expected Results: No dns query if in /etc/host.conf order hosts, bind multi on If dns query is imperative then use dns query for ipv4 if ipv6 is disabled.
you requested the domain be resolved fully, and your /etc/hosts doesn't provide an entry, so having it hit the network is to be expected. it looks like your hostname is set to "vx-macro" but your /etc/hosts only has "vx-beta" entries. `hostname -f` merely calls gethostbyname() which allows for either IPv4 or IPv6 to be returned. it could probably be made more explicit, but this code base isn't really recommended for improvements ... glibc does not respect USE=ipv6. its resolver will attempt IPv4 and IPv6 in parallel iirc. there is no support for disabling this behavior. it shouldn't be a problem if you have no IPv6 connectivity. net-tools does not respect USE=ipv6 either. it could be made to handle this USE flag, but it wouldn't prevent triggering of DNS IPv6 lookups in the current code base. it's not clear to me what the actual problem is you're having. that IPv6 lookups are sometimes triggered (and then immediately rejected) doesn't seem like a big deal.
Sorry change every occurance of vx-beta with vx-marco ( cut and paste mistake from other vm) . hostname=vx-marco.intranet.test.it Ok is not a big deal or problem but why hostname -f triggers a dns query instead looks in /etc/host ? when cat /etc/host.conf order hosts, bind multi on and cat /etc/hosts 127.0.0.1 vx-marco.intranet.test.it vx-marco localhost
(In reply to marco from comment #2) because you've configured your system to search dns: cat /etc/nsswitch.conf hosts: files dns and hostnames can have aliases. so when `hostname` calls gethostbyname(), it tries to find the host as well as all of its aliases, which means it finds both the entry in /etc/hosts and via dns. the fact that it uses IPv6 is due to hostname.c itself uses PF_INET6 when IPv6 support is available. i've added a USE=ipv6 flag to the latest ebuild, but otherwise, i don't see what you describe as a bug. http://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82bbf124f11397a2e97d821036300532c65c8567
Ok, thanks for the explanation and for the USE flag :)