Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Host Name Vs Canonical Host Name

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?

like image 996
Aryan Avatar asked Oct 01 '12 07:10

Aryan


People also ask

What is a canonical hostname?

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.

What does canonical name mean in DNS?

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.

What is the difference between host name and domain name?

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.

What is canonical name in Active Directory?

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.


1 Answers

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.

like image 165
Duncan Jones Avatar answered Oct 01 '22 07:10

Duncan Jones