InetAddress.getCanonicalHostName() method is specified to do best effort. But depending on the system configuration, we may not be able to return FQDN.
In order for us to further the investigation, please provide us with your system configuration files, such as the hosts, your host name search path, your nslookup results on ptr record for your IP address.
In the meantime, here's several things you can check:
1. Check your nsswitch.conf file or equivalent. On linux, you can use linuxconf to check your hostname search path. Does it contain DNS? if not, that could be the problem, 'cause usually hosts file or nis doesn't contain FQDN/IP mappings.
If your host name search path do contain DNS, AND it precedes either hosts or other name lookup mechanisms, try the following:
2. Do a nslookup. issue a ptr command for your ip address 220.127.116.11. does it return a FQDN? if it does, your DNS server does contain an A record for your machine. otherwise it doesn't. In case it doesn't, you will have to additional things to configure the FQDN/IP mapping, such as add appropriate entries to the DNS database.
If your name search path does contain DNS, but it's not the first in the search path. Furthermore, you can't change the search sequence on your system, you can do the following:
3. Specify the JNDI DNS service provider to bypass the default system name service provider. Use the properties defined at http://java.sun.com/j2se/1.4/docs/guide/net/properties.html and look for JNDI DNS service provider settings.
In glibc2.2.4 the IPv6 support in libnss_dns.so was moved to
to a libnss_dns6.so. This means that IPv6-enabled applications
using getaddrinfo/getnameinfo need /etc/nsswitch.conf changed to
search the hosts database using "dns6" instead of "dns". In
order words, "dns" is IPv4 only, and "dns6" is IPv4 and IPv6.
SuSE 8.0 ships with IPv6 compiled into the kernel and glibc2.2.5.
However it ships with /etc/nsswitch.conf configured to use "dns".
This means that IPv6 lookups and reverse lookups aren't possible
with an out-of-the-box SuSE 8.0 installation. Hopefully SuSE will
J2SE 1.4.x is IPv6-enabled. When run on a machine with IPv6
enabled java.net.InetAddress's default name service provider
will use getaddrinfo/getnameinfo to do lookups and reverse
lookups resp. Reverse lookups of IPv4 addresses are done
by providing an IPv4-mapped IPv6 address to getnameinfo. If
/etc/nsswitch.conf is configured to search "dns" then this
fails if glibc2.2.4 or newer is installed. RedHat 8.0 uses
their own glibc2.2.93 and this is why the problem isn't observed
on RedHat. On reflection the right thing would have been to
provide the IPv4 address to getnameinfo rather than assuming
that getnameinfo can handle an IPv4-mapped IPv6 address.
Note that the issue isn't specific to the getCanonicalHostName
method. Any reverse lookups via InetAddress.getByName will
also run into this issue. This means that most applications
using J2SE 1.4/1.4.1 on SuSE 8.0 will run into this issue.
In the case of SuSE 8.0 the issue can be worked around by changing
the hosts entry in /etc/nsswitch.conf to use dns6 instead of dns.
Alternatively J2SE can be configured be IPv4-only by running it
with java.net.preferIPv4Stack property set to "true". Yet another
workaround is to use the DNS name service provider for InetAddress
by configuring the sun.net.spi.nameservice.provider.1 system property
If this issue isn't addressed in 1.4.2 then we should try to get
it documented as a post-installation task for SuSE 8.0.