Reputation: 21
I have a program (written in C) that uses getaddrinfo()
and its first parameter is the host name that I want it to get address information about, let's say it is "domain". In my /etc/hosts
file on the same machine I can see that "domain" is supposed to resolve to 192.168.1.200. When I run the program it hangs on this call every time and cannot get the address information. However, if I replace "domain" with the actual IP Address, it works just fine.
By the way, this problem didn't exist a week or so ago, it is a new problem that has suddenly reared it's ugly head. I am fairly certain that something must have been done to this machine in the last week, and I have attempted to verify this with our other staff, but they also have no idea why this would occur.
So, my question is, does anyone out there have any idea what this would suddenly be occurring? What can I check to verify that it is configured how it should be? Thanks in advance.
Upvotes: 0
Views: 3699
Reputation: 215193
Are you using Linux? My guess is that you've messed up something with the libnss
mess glibc uses to route all its name lookups (hostnames, usernames, group names, etc.), perhaps by a botched glibc upgrade. Try running your program with strace
and see if it's trying (and failing) to open libnss_*
files. Also look in /etc/nsswitch.conf
to make sure the hosts:
line reads hosts: files dns
. man nsswitch.conf
could be helpful.
Upvotes: 1