Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got 2 machines on the same sub-net running Debian 5.0. They use the same DNS (/etc/resolv.conf), they route to the same gateway (#route) and they have the same iptables settings (#iptables -L). I can ping from both of them, both to IP addresses and to host names. I can run #host www.google.com and get the same results on both of them. But the problem is that on one of them, I can't wget or curl.

So on machine 1 everything is OK, but on machine 2 (with the same settings as machine 1) I can't wget or curl.

The error I get is:

# wget google.com
--2009-10-20 16:38:36--  http://google.com/
Resolving google.com... failed: Name or service not known.
wget: unable to resolve host address `google.com'

But on machine 1 it has no problem to wget or curl and returns:

# wget google.com
--2009-10-20 16:43:55--  http://google.com/
Resolving google.com... 74.125.53.100, 74.125.45.100, 74.125.67.100
Connecting to google.com|74.125.53.100|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
...
Saving to: `index.html.3'

Etc.

I'm hoping someone here can point me in the right direction here so that I can possibly fix this issue :)

share|improve this question

migrated from stackoverflow.com Oct 20 '09 at 16:44

This question came from our site for professional and enthusiast programmers.

    
This is most probably not related to wget but to a networking issue. –  jldupont Oct 20 '09 at 16:43
    
do you have a proxy setting in the environment .. my work machine did :-( –  lexu Oct 20 '09 at 16:44
    
Try "host google.com", not "host www.google.com", on server 2. –  Bill Weiss Oct 20 '09 at 17:43

6 Answers 6

Check your /etc/nsswitch.conf file (or whatever the equivalent is on Debian if it's not that).

host and nslookup always do DNS lookups.

However other applications will look in NSS first for other naming systems (e.g. /etc/hosts, NIS, etc). If something else is configured but not working it could prevent the application from ever trying the DNS.

share|improve this answer
1  
The canonical way to check the resolver is running getent hosts google.com. This uses nsswitch.conf and then resolv.conf as required. –  Joe Nov 5 '09 at 19:08

Thanks for the answers you guys!

It was the nsswitch.conf file. I had setup LDAP from a tutorial that told me to use this line in hosts:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4

When I changed it to this:

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

It works without a problem. So I guess the nsswitch config file was making it return null if not found in files or mdns4_minimal, right?

Thanks for your help!

share|improve this answer
3  
You should probably accept Alnitak's answer. –  Dan Carley Oct 21 '09 at 13:23
    
Yeah, how do I do that? :-/ –  Maggi Trymbill Oct 26 '09 at 21:08
    
Accept by clicking the "V" next to the vote score. :) –  Redsandro Mar 31 '13 at 21:36

Could there be an invalid proxy configured on the machine with the error? Try this:

# wget --no-proxy google.com
share|improve this answer

try

nslookup google.com

so that we see what DNS servers you are using on both boxes.

share|improve this answer

The first thing to try is checking whether DNS works correctly.

# host google.com
google.com has address 74.125.67.100
google.com has address 74.125.45.100
google.com has address 74.125.53.100

If you don't get that response, check /etc/resolv.conf and find the name servers listed in that file. Can you ping each of them?

Try querying each of them individually:

# host google.com 12.34.56.78

Can you resolve another host?

share|improve this answer

I had the same problem, but next to changing /etc/nsswitch.conf:

hosts: files dns mdns4_minimal [NOTFOUND=return] mdns4

I also had to change the name servers:

Change /etc/resolv.conf so it points to the google nameservers. The ones added by network manager don't work for me.

# RED 2013-03-31
nameserver 8.8.8.8
nameserver 8.8.4.4
share|improve this answer
    
Thanks, anonymous, for the constructive comment on the downvote. –  Redsandro Sep 23 at 11:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.