4

I have a CentOS 7 machine running in VirtualBox. It's connected to a host-only network. The /etc/hosts file contains the following:

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost4 localhost4.localdomain4
192.168.56.102 prospero.localdomain prospero
192.168.56.105 ariel.localdomain ariel

If I ping ariel.localdomain, it pings 192.168.56.105 as expected:

# ping -c1 ariel.localdomain
PING ariel.localdomain (192.168.56.105) 56(84) bytes of data

If I ping6 ariel.localdomain, it pings ::1, which I did not expect:

# ping6 -c1 ariel.localdomain
PING ariel.localdomain(localhost (::1)) 56 data bytes

Additionally, I can ping6 a non-existent foo.localdomain and get the same response, which I definitely did not expect:

# ping6 -c1 foo.localdomain
PING foo.localdomain(localhost (::1)) 56 data bytes

Why does ping6 resolve *.localdomain to localhost?

Since there are no DNS servers on the host-only network, queries that rely on DNS time out, e.g.:

  • nslookup
  • dig
  • host
2

Judging by your hosts file, the answer to the question "what is the IPv6 address of ariel.localdomain" is not coming from it but, most probably, from a DNS server which would be configured to answer ::1 to any request of the type *.localdomain (BTW, I would not be surprised that foo.localdomain would also resolve to 127.0.0.1 in the IPv4 domain).

When using nslookup (or dig, or hosts) in debug mode, you can figure out where the information is coming from. See the first two lines in the (fictitious) example below:

$ nslookup -debug -type=AAAA foo.localdomain
Server:     ns1.google.com
Address:    216.239.32.10#53
...
foo.localdomain has AAAA address ::1

Finally, note that localdomain is usually used for your loopback network (127/8) and not for your LAN (192.168.56/24 in your case). Hosts xxx.localdomain are generally expected to be local to your machine (i.e. with an IPv4 address 127.x.x.x). This is just a convention, though, but that may explain why you would have a DNS answering this way.

  • I'm using a host-only network adapter. nslookup, dig, and host connections time out. I'll edit the question to reflect this info. – cherdt Dec 30 '16 at 20:30
  • @cherdt strace getent hosts foo.localdomain may give you some hints on what exactly is answering you. – xhienne Dec 30 '16 at 21:11
  • Thanks, I posted the strace output to http://termbin.com/zq7u. I'll take a look and see what I can figure out. – cherdt Dec 30 '16 at 23:19
  • @cherdt From your strace output, I can only see that it tries unsuccessfully to reach a local DNS server (you must have 127.0.0.1 in your resolv.conf). From what follows, I don't understand how it can resolve foo.localdomain. – xhienne Dec 31 '16 at 0:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.