JDK-6507299 : InetAddress.getLocalHost() gives 127.0.0.1 for Solaris 10 local zones
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 5.0u4
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2006-12-21
  • Updated: 2010-04-02
  • Resolved: 2007-01-08
Related Reports
Duplicate :  
Description
Customer is using Solaris 10 zones and WebLogic. They use java.net.InetAddress to get all the IP addresses of a server.

For the global zone, they observe InetAddress.getLocalHost() gets the actual IP address of the server. This is passed to WebLogic where it adds the loopback address to the list of IP addresses.

For local zones, they observe InetAddress.getLocalHost() gets the loopback address. This is passed to WebLogic, where it skips adding the loopback address. They report the server never gets the actual IP address of the server.

This looks similar to bug 4435662. But that bug was for RedHat, and not for local zones in Solaris 10. The customer does not want to use the workarounds in this bug, editing /etc/hosts or alternatively updating /etc/nsswitch.conf to query DNS beforing querying /etc/hosts.

Customer questions why does a local zone get created by default with just the loopback
interface in this file?  They don't want to make a change to the /etc/hosts file if this is going to cause additional issues. They don't want to change their /etc/nsswitch.conf file for performance reasons.  Thats an established default to have files searched first on all of their solaris servers.

Here are the results of 'ifconfig -a' and the /etc/hosts for the global zone and the local zone.

TUSSIN (global zone)

tussin:/#
# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232
index 1
        inet 127.0.0.1 netmask ff000000
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1
        zone tussinz2
        inet 127.0.0.1 netmask ff000000
lo0:2: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1
        zone tussinz3
        inet 127.0.0.1 netmask ff000000
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1
        zone tussinz1
        inet 127.0.0.1 netmask ff000000
lo0:4: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1
        zone tussinz4
        inet 127.0.0.1 netmask ff000000
ce0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.12.10.129 netmask ffffe000 broadcast 10.12.31.255
        ether 0:3:ba:78:3b:6b
ce0:1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone tussinz2
        inet 10.12.11.14 netmask ffffe000 broadcast 10.12.31.255
ce0:2: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone tussinz3
        inet 10.12.11.76 netmask ffffe000 broadcast 10.12.31.255
ce0:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone tussinz1
        inet 10.12.10.43 netmask ffffe000 broadcast 10.12.31.255
ce0:4: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        zone tussinz4
        inet 10.12.11.82 netmask ffffe000 broadcast 10.12.31.255

# cat /etc/hosts
127.0.0.1 localhost
10.12.10.129  tussin tussin.oz.convergys.com loghost



TUSSINZ1

tussinz1:/#
# ifconfig -a
lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu
8232 index 1
        inet 127.0.0.1 netmask ff000000
ce0:3: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 10.12.10.43 netmask ffffe000 broadcast 10.12.31.255
tussinz1:/#
# cat /etc/hosts
#
# Internet host table
#
127.0.0.1       localhost       loghost tussinz1

Comments
EVALUATION The line :- 127.0.0.1 localhost loghost tussinz1 in /etc/hosts file cause InetAddress#getLocalHost() to return 127.0.0.1. The evaluation of CR 4435662 also applies here. The submitter needs either to edit /etc/hosts or /etc/nsswitch.conf, or to use java.net.NetworkInterface class to enumerate all NICs and bounded addresses. Will close this as a duplicate of 4435662. Hi All, I have a quick question on closing this as a duplicate of 4435662. Bug 4435662 is an issue with RedHat. This current bug is about Solaris 10 and local zones. It has nothing to do with RedHat. So why is this a duplicate of 4435662?
05-01-2007