Can anyone please explain me the difference between Host Name and Canonical Host Name?
I am currently using InetAddress class to fetch host name using the IP Address. I came across these 2 APIs. So I am just wondering, which one I should opt for?
A canonical name (CNAME) is a type of Domain Name System (DNS) database record that indicates that a domain name is the nickname or alias for another domain name. Also referred to as the "true name," the CNAME is especially important when multiple services run from a single IP address.
A Canonical Name or CNAME record is a type of DNS record that maps an alias name to a true or canonical domain name. CNAME records are typically used to map a subdomain such as www or mail to the domain hosting that subdomain's content.
The host name represents the network or system used to deliver a user to a certain address or location. The domain name represents the site or project that the user is accessing. One example is the use of various networks to access educational websites.
The canonical name is an attribute in Microsoft Active Directory that describes the location of an object in the directory. The canonical name of an object can be seen within the Active Directory Users and Computers by ensuring that the Advanced Features option is ticked on the view menu.
There are a few difference between the two:
getCanonicalHostName()
will attempt to resolve the FQDN. Therefore, you would get foo.mycompany.com whereas getHostName()
might just return foo.
getCanonicalHostName()
will always do a reverse DNS lookup, whereas getHostName()
would return the stored hostname if you supplied one in the InetAddress
constructor.
I suspect you will be wanting to use getCanonicalHostName()
if you are intending to map IP addresses to host names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With