Link to home
Start Free TrialLog in
Avatar of unluckynelson
unluckynelsonFlag for South Africa

asked on

Windows Server 2008 with DNS doesn't resolve Localhost locally

Hi All

I have a pretty weird issue... After installing DNS on my MS Server 2008 looking up localhost on the server doesn't resolve...
I've tried adding Host records to localhost even installed WINS but keep getting Non-existent domain when looking up localhost.

Is this by design? or can I resolve this issue?

Thanks in advance...
Avatar of Justin_W_Chandler
Justin_W_Chandler
Flag of United States of America image

you must add it to the LMHOSTS file, not the HOSTS file.
Avatar of unluckynelson

ASKER

Ok, thanks for reply...
I searched my box for a lmhosts file but couldn't find any... except lmhosts.sam... which was a sample file
So I created one in the same place windows\system32\drivers\etc....

Sorry didn't work...

Any other ideas?
Avatar of Chris Dent

Localhost is defined in Hosts, not LMHosts.

> but keep getting Non-existent domain when looking up localhost.

Exactly how are you doing  that? "nslookup localhost" will fail, but "ping localhost" should work.

Chris
CHRIS: I'm sorry but you're mistaken. The hosts file identifies qualified domain names and subdomains (i.e. localhost.com or where.localhost.net). The LMHOSTS file identifies netbios names (i.e. localhost)

localhost is a reserved netbios name by the system and it should be unnecessary to add it to LMHOSTS. I'm not sure where your problem presently lies. Can you run an NSLOOKUP LOCALHOST and give the output? If your machine is a domain member you should see an entry for localhost.domain.com.

Justin Chandler

Sorry Justin, but I'm not.

Have you actually opened hosts? Because if you do, you'll see an entry just like this one:

127.0.0.1       localhost

LMHosts, if it exists as more than a sample file, by default contains nothing more than comments (prefixed with #). It is used only to map NT LAN Manager names to IP addresses.

Hosts is used to map hostnames to IP addresses. That doesn't have to be a fully qualified name, it can be single label names as is the case with localhost or any other single label name you might choose to add.

DNS can also be used to query "localhost" if, and only if, a zone is configured for that. Localhost tends to be, but is not always, present as a default zone file. Whether or not it exists on the DNS server in question is moot if the Hosts file contains the default entry above as Hosts is queried before DNS by the DNS Client (nslookup bypasses the DNS Client entirely).

As such, NsLookup can return an NXDOMAIN response where Ping might return 127.0.0.1. This is because Ping will resolve using the DNS Client, and therefore pay attention to Hosts, where NSLookup queries the name server directly which may not necessarily contain an answer for localhost.

Chris
Indeed you are right. My mistake. I had a brain fart, yet clearly contradicted myself as I suggested using NSLOOKUP LOCALHOST. As NSLOOKUP can be used to query localhost, it is definitely a hostname that should be located in the hosts file. *smacks forehead*

Justin Chandler
One thing to note, however... even without a hosts file, localhost should resolve to the loopback IP. This means his problem lies elsewhere, wouldn't you agree?

Justin Chandler

Yep, it should, because Windows likes to resolve that name regardless of what you put in Hosts.

But I suspect the reason for failure is that this is being tried:

NsLookup localhost

That will only work if nslookup is explicitly instructed to resolve it as a single label name:

NsLookup localhost.

The terminating period has NsLookup pass the request to the DNS server without appending any suffixes. Without it NsLookup will append each Suffix (Primary, and any list) then give up, never requesting the name alone. That behaviour can be seen using Set Debug, or Set D2 within the NsLookup prompt.

Chris
Thanks guys for your responses.

'Nslookup localhost' returns non-existent domain.
'ping localhost' does the same...
So does 'nslookup localhost <server-ip>' or <server-fqdn>
My server is not part of a domain (which i suspect might be the cause from your responses) because i use it as a super-workstation. I don't want it part of a domain or setup active directories just to make it resolve localhost...

My only reason for trying to resolve this issue is because it is annoying to replace all my php and mySql code and DW sites with an IP address...

Thanks again...  







Could you verify that Hosts (when you open it in Notepad) does contain a "localhost" entry and that "Users" have Read and Execute permission when you look at the Security?

Chris
Hi Chris

Yes, the host file does contain the entry:
127.0.0.1         localhost

I have checked now and ping localhost does resolve to 127.0.0.1 but times out? Apologies, please correct my previous comment..

What does that leave us with?

Thanks again
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I arse an idiot... It was 2008's advance firewall stuff... stopping the service worked...