Why can't my browser resolve a hostname through /etc/hosts?

0

I set up a Apache2 on a new Solaris machine on my company's internal (firewalled) network and configured it for name-based virtual hosts.

We don't yet have a domain for the new machine, so I created my own, "lsiden.net", and named the host something like "myhost.lsiden.net" in the httpd.conf <VirtualHost> directive.

Since no such domain is registered, I created the entry "w.x.y.z myhost.lsiden.net" in my /etc/hosts file. (I will delete it when we get a real domain name.)

I can ping myhost.lsiden.net but if I type it in either IE7 or Google Chrome 10, it won't resolve. Is there something that is preventing each browser from looking in the /etc/hosts file?

(In order to access my company's VPN, I have to use the machine that they configured for me which was provisioned with Windows XP. So /etc/hosts is actually something like c:\Windows\system32\drivers\etc\hosts, but that shouldn't matter.)

Lawrence I. Siden

Posted 2011-03-24T22:22:33.937

Reputation: 103

Check your /etc/nsswitch.conf and /etc/resolv.conf. Both control how DNS resolution works on the local machine. – None – 2011-03-24T22:25:41.597

2You use IE/Chrome on the Solaris? – M'vy – 2011-03-24T22:27:15.253

No. A Solaris machine hosts the site. I must use IE or Chrome (or FF) on a Win-XP computer to access the site because of VPN and company IT restrictions. – Lawrence I. Siden – 2011-03-25T01:01:08.153

On Windows, there is no nsswitch.conf or resolv.conf. Is there some equivalent that controls whether or not DNS will look first in .../etc/hosts? – Lawrence I. Siden – 2011-03-25T01:05:15.467

I found this post that suggested that I restart the DNS cache on Windows. Tried it. Can ping it with my URI, but still can't reach it from the browser. Rats!@

– Lawrence I. Siden – 2011-03-25T01:25:56.083

Answers

1

As far as 'why does one work and not the other' one thing to remember is that ping uses a different protocol (icmp) than http (tcp). Can you check firewalls on your Windows host? A lot of VPNs are configured to firewall certain things.

The next step after ping is the old webmaster (I'm dating myself by using that term) tool: telnet.

Can you try:

telnet <machine> <port>

from your Windows box.

If this doesn't connect, you have connection issues. Possibly a firewall, or something else.

If it does connect, try typing:

GET / HTTP/1.0
Host: <nameOfVirtualHost>

ReturnReturn

Which then should show you your page.

I'd flush the system DNS cache if you haven't yet:

ipconfig /flushdns

Browsers themselves may use a DNS cache. I know Chrome does, couldn't find a way to flush it. There's a Firefox plugin that flushes DNS cache

Rich Homolka

Posted 2011-03-24T22:22:33.937

Reputation: 27 121

First, I had to reboot Windows ;). Then I tried your telnet suggestion. I didn't get back a page but I got this in the access log: "10.195.51.65 - - [25/Mar/2011:12:25:42 -0400] "GET GET\b\b\b\b\b\b\b\b\bGET / HTTP/1.0" 400 226". The backspaces are a consequence of my term (Putty) not echoing anything to me in telnet so I can't see WTF I'm doing! But something is definitely working now! Thanks! – Lawrence I. Siden – 2011-03-25T15:30:47.237

1

(Expanding on M'vy's comment)

It is the client which performs the name resolution.

On windows this can be done through the hosts file (link includes all resolution methods).

Happy ... networking.

pst

Posted 2011-03-24T22:22:33.937

Reputation: 206

I already said I put entries in /etc/hosts. That's what this question is about. – Lawrence I. Siden – 2011-03-25T01:03:06.997

@Isiden you mentioned /etc/hosts, which makes it sound like a UNIX machine you were editing on, and later mentioned it was the Windows equivalent. That's what @pst was responding to. – Rich Homolka – 2011-03-25T03:17:53.537