If i try to dig facebook.com instead of www.facebook.com I obtain the same IP address but the first one is in "A" record for facebook.com, which is domain name and the second one is from "A" record for a hostname www.facebook.com. Why does domain (not hostname of http server) has an IP?
dig facebook.com +short
***.***.***.***
dig www.facebook.com +short
star-mini.c10r.facebook.com.
***.***.***.***
I know that star-mini in this case is canonical name for www... In fact the second case is correct because I obtain an IP associated to this star-mini machine. I can't understand the first case.
facebook.com is what in DNS world is called an APEX domain name and can only resolve to an IP address, which only works with A records.
www.facebook.com is a subdomain name and can point anywhere using CNAME and A records.