Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a gentoo box on my homenetwork that I'm trying to SSH into via W7 client but although I can do it via IP address when I try the hostname it won't find it. Also get a DNS error

socket.gaierror: [Errno -2] Name or service not known

when I try to startup a http server on the gentoo. I assume as this is a dns error that these issues are related.

It was working a few months ago when I last logged in so I'm not sure what's changed in the meantime?

EDIT:

Ping fails on supplying hostname too but again, pinging the IP works fine.

On my router firmware I have port forwarding setup to the linux hostname for ssh and http which works fine though. So how can router resolve hostname but not my windows box/the linux http server itself?

EDIT 2:

I set the static ip/hostname in etc/hosts and the http server now starts up, indicating gentoo couldn't resolve it's own name. Confused as to how that can be?

share|improve this question
add comment

3 Answers

up vote 1 down vote accepted

You have a problem with name resolution on the client you try to connect from (W7).

All connections are made to a destination IP address. If you supply a name, the computer first resolves that name into an IP address. This is where you fail today.

If your gentoo box / home router's IP address can't be looked up from either the hosts file, or with an A (or AAAA for IPv6) record in DNS (possibly via a CNAME), your windows machine won't understand what IP the gentoo box has.

To be able to give a good answer to your question, we need a bit more information from you, describing the network setup a bit, so we don't make wrong guesses. For instance:

  • are the windows and gentoo boxes both on the "inside" network?
  • are they both configured as DHCP clients?
  • is the router the only DHCP server on the internal network?

Did you use any DynDNS service when it was working earlier, or has the W7 installation changed somehow? (Different PC, reinstall, virus, etc?) Perhaps you had an entry in the hosts file before, when it was working, and it is now missing.

Why the router can figure out the internal/private IP address of the linux box while the windows box cannot, is because they use different sources for their name information. Maybe the router itself has that information. Is it also a DHCP server? Maybe that's why the router knows.

EDIT (2012-08-06): Based on new input,
On the gentoo box, make sure you have an entry in /etc/hosts that looks like this:

192.168.0.3   hostname.domain.tld  hostname

(replace 192.168.0.3 with the real (internal) IP address of the gentoo server, and hostname.domain.tld to be the fully qualified domain name you wish to use, and the last word on the line to be the hostname without the domain (ie, the word before the first .).

Put the same line in the %WINDIR%\System32\drivers\etc\hosts file, but remember that windows name lookups of your gentoo box will be then taken from that file, and not from DNS.

This should make the name lookups work (locally) on both the gentoo server itself, and the windows client, without consulting DNS.

In /etc/apache2/vhosts.d/00_default_vhost.conf (if that's where your web server is configured), make the ServerName entry match the FQDN (hostname.domain.tld) that you have in the /etc/hosts file.
This should allow apache to start without warnings.

share|improve this answer
    
a) both on inside b) not sure, how can I check this? c) yes. Used both a dyndns service and straight hostname connection before. DynDNS (no-ip.org) works now too, but hostname addressing fails. –  user1561108 Aug 3 '12 at 13:45
add comment

Probably you are not using the correct name. I can imagine you are using something like an URL (http://host_name.com/). Try tou use only the name host_name.com. We need more info about the name you are using.

share|improve this answer
    
it's just a hostname on my local network - and I'm trying to login via ssh not http. The DNS error detailed above is when run the http server startup script. –  user1561108 Aug 3 '12 at 8:45
    
do you receive answers using ping to this host using his name? –  logoff Aug 3 '12 at 10:04
    
no, could not find host. IP address pings ok. –  user1561108 Aug 3 '12 at 11:13
    
it seems that your network name is not being resolved at all. are you trying to access outside from your network? if the answer is no, your router does not affect at all. –  logoff Aug 3 '12 at 12:42
    
what do you mean by access outside from my network? I can access the internet from my W7 machine if that's what you mean. And all devices have valid IP addresses handed out by the router. –  user1561108 Aug 3 '12 at 13:50
show 1 more comment

Turns out I forgot that I upgraded routers in between now and my last access to linux box. The new router forces the client to use the remote ISP DNS servers so my home network computers aren't able to lookup against eachother.

As the IPs are statically assigned I ended up editing the individual hosts file manually.

share|improve this answer
add comment

Your Answer

 
discard

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

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