[CentOS] Incomplete host name resolution

Adrian Constantin

terminatorul at gmail.com
Wed May 2 21:35:36 UTC 2012


Hello

I happen to have two network interfaces on my new, up-to-date, CentOS 
6.2, named eth0 and virbr0 (3 of them if I include the lo interface).

However the system APIs like getaddrinfo() only return the address for 
the virbr0 interface (which was created by the CentOS installation), 
when I would like to have them both.

Even if I give the configured eth0 address explicitly to getnameinfo(), 
it can not perform the reverse lookup to my hostname, and returns a 
string with the same numeric IP address given as argument. I also can 
not get the list of samba name aliases for my host name.

I can happily ping my host from a different computer on the eth0 
network, so the nmb service binds on eth0 and works as expected.

I have installed and configured smb, nmb and winbind services, and I 
have added 'wins' to /etc/nsswitch.conf, so my hosts line there looks like:
	hosts:      files wins mdns4_minimal [NOTFOUND=return] dns

Is there something I should do for wins name service to return all IP 
addresses ?

Are there some similar settings that I need to do in order to get the 
reverse lookup to work ?

For reference here are my system information and application output, as 
follows.

Here are my interfaces:
[adrian at adrian projects]$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1C:C0:DA:63:75
           inet addr:10.0.0.154  Bcast:10.255.255.255  Mask:255.0.0.0
           inet6 addr: fe80::21c:c0ff:feda:6375/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:1222539 errors:0 dropped:0 overruns:0 frame:0
           TX packets:708669 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:1491421614 (1.3 GiB)  TX bytes:136206085 (129.8 MiB)
           Interrupt:20 Memory:d0600000-d0620000

lo        Link encap:Local Loopback
           inet addr:127.0.0.1  Mask:255.0.0.0
           inet6 addr: ::1/128 Scope:Host
           UP LOOPBACK RUNNING  MTU:16436  Metric:1
           RX packets:751048 errors:0 dropped:0 overruns:0 frame:0
           TX packets:751048 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:208785657 (199.1 MiB)  TX bytes:208785657 (199.1 MiB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:92:B0:1A
           inet addr:192.168.122.1  Bcast:192.168.122.255 
Mask:255.255.255.0
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:4038 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:0 (0.0 b)  TX bytes:393067 (383.8 KiB)

And here is how my applications behave:
[adrian at adrian projects]$ python
Python 2.6.6 (r266:84292, Dec  7 2011, 20:48:22)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import socket
 >>> socket.gethostbyname_ex('adrian')
('adrian', [], ['192.168.122.1'])
 >>> for a in socket.getaddrinfo('adrian', None, 0, 0, 0, 
socket.AI_CANONNAME) :
...     print a
...
(2, 1, 6, 'adrian', ('192.168.122.1', 0))
(2, 2, 17, '', ('192.168.122.1', 0))
(2, 3, 0, '', ('192.168.122.1', 0))
 >>>
[adrian at adrian projects]$

As you can see there are no name aliases returned, and there is only one 
IP address given for my host name.

You can see my samba name aliases here:
[adrian at adrian projects]$ nmblookup -A -T 10.0.0.154
Looking up status of 10.0.0.154
         ADRIAN          <00> -         B <ACTIVE>
         ADRIAN          <03> -         B <ACTIVE>
         ADRIAN          <20> -         B <ACTIVE>
         ..__MSBROWSE__. <01> - <GROUP> B <ACTIVE>
         TERMINATORUL    <00> -         B <ACTIVE>
         TERMINATORUL    <03> -         B <ACTIVE>
         TERMINATORUL    <20> -         B <ACTIVE>
         TIMOTHY         <00> -         B <ACTIVE>
         TIMOTHY         <03> -         B <ACTIVE>
         TIMOTHY         <20> -         B <ACTIVE>
         TOUGHY          <00> -         B <ACTIVE>
         TOUGHY          <03> -         B <ACTIVE>
         TOUGHY          <20> -         B <ACTIVE>
         WORKGROUP       <1d> -         B <ACTIVE>
         WORKGROUP       <1e> - <GROUP> B <ACTIVE>
         WORKGROUP       <00> - <GROUP> B <ACTIVE>

         MAC Address = 00-00-00-00-00-00

(namely adrian, terminatorul, timothy, toughy).
Trying to resolve my hostname to an IP address with nmblookup also 
returns just one of the IP addresses:

[adrian at adrian projects]$ nmblookup adrian
querying adrian on 192.168.122.255
192.168.122.1 adrian<00>
[adrian at adrian projects]$




More information about the CentOS mailing list