cancel
Showing results for 
Search instead for 
Did you mean: 

DNS behaviour

leng
Grafter
Posts: 78
Thanks: 1
Registered: ‎06-12-2007

DNS behaviour

This is not a plusnet related problem, but I thought someone out there might be able to explain what is going on.
Some time ago to bypass a DNS server issue (also not plusnet related) I added a line to the "hosts" file of the form
    a.b.c.d  www.site.org
Recently site.org moved to a new server (e.f.g.h) but because of this line I was still accessing the old server from my browser.  This gave a "you are using the old server" page.
Now, I had forgotten the hosts entry so I tried entering e.f.g.h manually on the browser url line.  To my great surprise this resolved to www.site.org and took me back to the old server warning banner.  I am at a loss to explain this behaviour unless the browser did a reverse lookup on e.f.g.h then a DNS lookup on www.site.org, which seems very inefficient.  I'd always assumed that entering a numeric ip address would bypass all lookup. 
Firefox and IE both behaved this way.  Can anyone tell me why?
2 REPLIES 2
David_W
Rising Star
Posts: 2,305
Thanks: 33
Registered: ‎19-07-2007

Re: DNS behaviour

Hard coded HTML on the web page?  You go to http:///123.123.123.123 for instance which brings up a web page, the web page has an image with <img=http://www.sitename.com/image.jpg>, your computer needs to look up www.sitename.com which is in your hosts file as http://321.321.321.321 so it resolves to that?  Or, if you try http://212.58.244.68 you'll get taken to www.bbc.co.uk, the address will change from numeric to www.bbc.co.uk so the same could be happening at site.org which again relies on your hosts file.
MJN
Pro
Posts: 1,318
Thanks: 161
Fixes: 5
Registered: ‎26-08-2010

Re: DNS behaviour

That's probably pretty much it. Many sites perform redirects such that regardless what the HTTP Host: header says, whether it be an IP address or anything other than www.site.com, it'll redirect to the canonical name of the site: www.site.com. Doing so helps maintain order at search engines etc because some engines might think, say, 'site.com' is different to 'www.site.com'. Indeed it may well be in some cases but if it isn't then each site can only seem half as popular hence search rankings get it if they're not forced to be one and the same.
To illustrate with an example, if you go to http://newtonnet.co.uk it'll redirect to http://www.newtonnet.co.uk. If you had www.newtonnet.co.uk in your HOSTS file then your setting would always end up taking effect. I had to intentionally prevent the redirect pattern matching from acting on just an IP address but if I hadn't then it'd exhibit exactly the same behaviour that you've been seeing.
Mathew