3

So it seems I can't browse a website by IP, but I can browse using it's hostname.

C:\Users\c>nslookup www.example.com
Non-authoritative answer:
Name:    cx-cdn-bre.gss.consultix.net
Addresses:  62.168.203.241
          62.168.202.241

Trying to access 62.168.203.241 is displaying an "nginx Internal Server Error" But if I access www.example.com, the page loads. How is this possible?

2
  • 6
    It is likely that multiple domains are served from the same server. In this case, the server relies on the headers of the request to specify what website to serve. If there is no default configured, then it will return a server error. – Worthwelle Sep 26 '18 at 21:00
  • Apache, Nginx and IIS prohibit direct access to websites through IP addresses to prevent malicious resolution. In general, websites are not allowed to access directly through IP addresses. Some websites do not restrict access by IP addresses, but when using IP addresses to access websites, they redirect IP addresses to the corresponding domain names. Of course, you can make adjustments to Apache, Nginx, and IIS to allow certain websites to access directly through IP addresses. – S.Leon Sep 27 '18 at 3:15
8

There are a variety of reasons this might be the case. Here are just a couple:

  • host headers - In short, the webserver might host multiple websites on a single IP address. Without the domain name, it cannot display the proper website.

  • load balancing or similar device - the IP address might not be for a website, but to a load balancer, which distributes network load to other devices.

  • name resolution - the name resolution to IP had been changed. For example, let's say the website's address has changed and you manually entered it into your HOSTS file to go to the proper IP.

3
  • 1
    Isn't the load-balancer case still just the same "Host headers" problem? – user1686 Sep 27 '18 at 5:13
  • @grawity Im just listing various reasons why. – Keltari Sep 27 '18 at 5:33
  • You're right. It's because of the headers and virtual host config. Basically, when I was requesting the GET method, host header was sending the IP, and the server was expecting the hostname. Hence the server's virtual host config refused my request and threw me "internal server error". I was able to test it using BurpSuite. I've requested the IP and passed the hostname in the host header, and the page loaded successfully. I've tested the vice-versa also, requested the FQDN and modifed the host header with the IP, and I got the same "internal server error". – catalin Sep 27 '18 at 15:10
5

Apache and nginx both (not sure about others....) can serve multiple sites from the same IP based on the host name that is used to connect and request the file(s).

But when you access the server via the IP address, there must be a virtual host defined to service the name used (the IP). The fact that the server is generating an error indicates that there is something "wrong" on the server's config - either it isn't set up to respond to the IP at all, or if it is responding and serving up a PHP or other script that script has issues of some type.

1
  • You're right. It's the virtual host config. Basically, when I was requesting the GET method, host header was sending the IP, and the server was expecting the hostname. Hence the server's virtual host config refused my request and threw me "internal server error". I was able to test it using BurpSuite. I've requested the IP and passed the hostname in the host header, and the page loaded successfully. I've tested the vice-versa also, requested the FQDN and modifed the host header with the IP, and I got the same "internal server error". – catalin Sep 27 '18 at 15:07
-3

Because the ip could point to the server but the hostname is merely pointing to a domain which could be a subdomain which could have some other ip all together.

A domain has 132.21.12.21 as ip (example, is made up number). A subdomain (meaning it has the same principal hostname and then something added to it) could have altogether a different ip and to be therefore in a different server.

Also domains can also make it so you can only enter into them through their designed places for security reasons, for example.

You need to think about it as minecraft buildings made of different blocks.

Edited to add a thought to the questioner: You know there is content which is volatile and in differnt parts right? For example, peer to peer, bittorrent etc. There are even botnets using peer to peer being nowhere and everywhere at the same time, and websites which shows content through peer to peer too. I can only hint the answer you want.

2
  • 3
    @FollowerOfLelouch - You should edit your answer, and improve it, instead of submitting comments. – Ramhound Sep 26 '18 at 23:00
  • 1
    @FollowerOfLelouch: The thing is, your "explanations" only keep repeating the same thing from OP's question. Why does Fastly say 'unknown domain'? That's not an explanation; that's what the OP was asking already. – user1686 Sep 27 '18 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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