On many Linux installations InetAddress.getLocalHost() may return an InetAddress representing the loopback address (127.0.0.1). This stems from many Linux installations configuring /etc/hosts to map the hostname to the loopback address. If the host has a static IP address then the /etc/hosts file should be corrected to map the hostname to the host address.
If DHCP is used in conjunction with dynamic DNS then there are two options:
- Change the name service search order in/etc/nsswitch.conf to use dns before the hosts file (ie: "hosts: dns files")
-or- - Configure InetAddress to use the DNS name service provider instead of the default provider (-Dsun.net.spi.nameservice.provider.1=dns,sun).