0

I tried to ping http://crashsafari.com in my CMD:

Output ->

Right there, it resolves http://crashsafari.com to 54.231.48.170 which is http://s3-website-us-east-1.amazonaws.com.

But,

http://crashsafari.com and http://s3-website-us-east-1.amazonaws.com are not the same when I type them in my browser and visit the website.

I want to know what exactly is happening? Where exactly does the problem exist?

techraf
  • 9,141
  • 11
  • 44
  • 62
Tilak Madichetti
  • 252
  • 1
  • 6
  • 16

1 Answers1

3

Where exactly does the problem exist ?

Nowhere. There is no problem.

With ping you are working only at the network layer and on this layer there is no such thing as a hostname, there are only IP addresses. And crashsafari.com has the same IP address as s3-website-us-east-1.amazonaws.com because this is just an alias (DNS CNAME):

$ dig crashsafari.com 
...
;; ANSWER SECTION:
crashsafari.com.        59      IN      CNAME   crashsafari.com.s3-website-us-east-1.amazonaws.com.
crashsafari.com.s3-website-us-east-1.amazonaws.com. 59 IN CNAME s3-website-us-east-1.amazonaws.com.
s3-website-us-east-1.amazonaws.com. 4 IN A      54.231.17.132

But when using a browser to access a site you are using the application layer protocol HTTP instead. Within this protocol the hostname is sent by the client (HTTP Host header) and thus different hostnames with the same IP address can be distinguished by the server. A request to http://crashsafari.com looks like this:

GET / HTTP/1.1
Host: crashsafari.com
...

whereas a request to http://s3-website-us-east-1.amazonaws.com looks like this:

GET / HTTP/1.1
Host: s3-website-us-east-1.amazonaws.com
...

And based on the Host header the server will use a configuration specific for the given hostname, which makes both sites look different even if they share the same IP address.

Steffen Ullrich
  • 184,332
  • 29
  • 363
  • 424
  • But these two hostnames are not same IP . – Tilak Madichetti Jun 15 '16 at 09:29
  • @TilakMadichetti: They are the same IP but a different hostname. In fact `crashsafari.com` is just an alias (CNAME) to `crashsafari.com.s3-website-us-east-1.amazonaws.com` which itself is a CNAME to `s3-website-us-east-1.amazonaws.com`. Using `dig crashsafari.com` will give you this information. – Steffen Ullrich Jun 15 '16 at 09:31
  • Oh.. okay Now I get it, just include this part in the answer.Thanks !! – Tilak Madichetti Jun 15 '16 at 09:32