Why do we need a hostname when we have an IP address. Some spoilers for retired box "Bank"

I just started on the Bank box. I noticed that the IP address for the box is not enough to navigate to the login page and that we needed to correctly guess the hostname of bank.htb.

I thought these were essentialy equivalent values? If all I’m doing is adding the IP address of bank.htb to my etc/hosts then why would the raw IP address just lead me to the default apache2 ubuntu page?

Thank you

They are not necessarily equivalent.

Think about it as a subdomain or something like this.

ryan.ryan.com may not be the same as ryan.com

In fact, can have multiple domain names. In other words, multiple domains can still have the same IP address.

If you digged further, you will see that in bank, there is /v ar/ww w/h tml AND /va r/ww w/ban k

These are 2 different folders that points to 2 different websites per se.

I hope this made it clear.

If you don’t configure bindings to virtual hosts, IP addresses and names are equivalent and just determined by DNS. But you can bind websites to ‘virtual’ host names.

A hosting provider can host websites for several customers at the same machine, using a single IP. The different sites are just distinguished by the host name (host header) the browser sends.