I just came across an issue, where I had to check if a path points into a windows share. Part of this problem is to check if host A is the same as host B. Where host A and host B can be one of the following {IPv4-Address, IPv6-Address, Hostname, FQDN}. As I do not need to be exact it’s enough to resolve and compare the IP-Addresses in my case.
But is there, theoretically, a method to check if the hosts are the same?
No, there is no general method to see if two identifiers (names or addresses) go to the same host. One example:
192.0.2.1and2001:db8::bad:dcaf. Are they the same? (Answer: cannot tell)There is no general concept of host identity in the Internet. Some protocols have such a concept, for instance SSH (connect to the hosts, see if the fingerprints match) or HIP (test the keys) but you depend on this protocol being activated for these specific machines.
Some heuristics may help (fingerprinting the machine, for instance) but it will be far from 100 %.