Jump to content
  • Advertisement
Sign in to follow this  
darklordsatan

[web] On IP and DNS

This topic is 4826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, I was recently making an app that would call a php script on a given X webserver. However, when I was trying to connect through a DNS (lets say, www.webserver.org/script.php), I tried to change the connection to an IP, and It didnt work. So I tried with another server, and it did worked using an IP instead of a DNS... So my question is, why is this kind of behaviour happening to some webservers not accepting connections when called with an IP, and others just plainly work like they should? I thought DNS were made so that us mortals wouldnt have to remember IPs, but I would have guess its the same thing connecting to a website with an IP, than with a DNS, which is just an alias for the IP. Take for example www.google.com: Trying to connect with its IP (or one of them), gives a positive result. 64.233.179.99 But for example, www.altavista.com, when acceded with its IP (66.94.229.254) redirects me to some website called "All the Web". Another weird example (well, weird for me, but hopefully it has an easy explanation) is when trying to connect to bloodshed.net through its IP (66.152.98.201); it basically shows an "IP registered with Webhost X" advertisement. What is going on here? Has your webhosting provider something to do here, or the fact the IPs havent been correctly registered to redirect to the website? Thanks

Share this post


Link to post
Share on other sites
Advertisement
When you request a webpage, one of the headers in the request is Hostname which is essentially that part after http:// and before the first / (i.e. the DNS name of the server).

Now, multiple DNS names can resolve to the same IP address and many ISPs host multiple websites on the one machine (hence the one IP address) and they use the DNS name specified in the Hostname HTTP header to differentiate between sites.

So if you just try to connect using the IP address, and multiple sites are hosted on the one machine, the web server doesn't know which site you're talking about and so you'll end up with the "hosted by XXX" message, or perhaps it'll just pick a "default" (which seems to be the case with the altavista site you mentioned).

Share this post


Link to post
Share on other sites
Thats good stuff to know. So I guess if I want to emulate that functionality I can make use of Virtual Hosts in Apache, for example.
Thanks a lot dude.

Share this post


Link to post
Share on other sites
AFAIR Host is actually only used in HTTP 1.1 requests so make sure you are using version 1.1 of the protocol if your building the requests yourself, see ftp://ftp.isi.edu/in-notes/rfc2616.txt chapter 14.23

Also it's not "hostname", it's just "host", here's a sample requset from the RFC:
GET /pub/WWW/ HTTP/1.1
Host: www.w3.org

/ Anders

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!