Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 521982 - sys-apps/net-tools: `hostname -f` triggers IPv6 DNS query even when no IPv6 configuration is present
Summary: sys-apps/net-tools: `hostname -f` triggers IPv6 DNS query even when no IPv6 c...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-02 15:39 UTC by marco
Modified: 2015-08-26 07:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marco 2014-09-02 15:39:44 UTC
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.
Comment 1 SpanKY gentoo-dev 2014-09-11 07:46:31 UTC
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.
Comment 2 marco 2014-09-16 13:55:18 UTC
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
Comment 3 SpanKY gentoo-dev 2015-08-26 03:54:43 UTC
(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
Comment 4 marco 2015-08-26 07:29:40 UTC
Ok, thanks for the explanation and for the USE flag :)