The installer should catch systems where TCP connections cannot be made to localhost

Description

Some systems are not running IPv6 (or have no IPv6 localhost interface configured), however they have
an IPv6 address entry for ::1 listed in the "localhost" record(s) in DNS or /etc/hosts along with the older
IPv4 127.0.0.1 entry. Java prefers IPv6 addresses, and if this case occurs and code won't try all
addresses returned for "localhost", some parts of OpenNMS will break.

Sometimes the address "127.0.0.1" will be used, and this has tended to be the preference to get
around these IPv6-related issues. Sometimes "localhost" will be used, but as users have run into this
problem in different places, it usually gets replaced with "127.0.0.1". It turns out that there are a few
cases where the Java static method InetAddress.getLocalHost() is used, which seems like it can cause
similar issues to using the "localhost" host name on improperly configured hosts. Here's an example:

http://article.gmane.org/gmane.network.opennms.general/15037

Environment

Operating System: All Platform: All

Acceptance / Success Criteria

None

Lucidchart Diagrams

Activity

Show:

Seth Leger August 12, 2011 at 9:59 AM

During 1.9 development, I added the InetAddressUtils.getLocalHostAddress() function that can be used to fetch an InetAddress that represents the localhost interface. This function behaves like option 3 in the previous comment. We still call InetAddress.getLocalHost() in a limited number of places in the unit tests but no runtime code depends on it. Marking as fixed.

Seth Leger (community account) September 3, 2010 at 5:07 PM

I just combed through all of our code to look for references to InetAddress.getLocalHost() (by doing a search in Eclipse: go to Search > Java... > getLocalHost(), and check Method, References). It looks like we handle failures to resolve in 4 ways (in order of popularity):

  • We set the address to "unresolved.host"

  • We set the address to "localhost"

  • We set the address to "127.0.0.1"

  • We throw an exception that should cause a startup failure or something similar

I think we should probably opt towards the 3rd option, setting the host address to 127.0.0.1 because this is the only option that doesn't result in more name resolution failures (like "localhost" or "unresolved.host" would). I'll try and take care of this as a bit of refactoring in the 1.9 branch.

Fixed

Details

Assignee

Reporter

Labels

Components

Fix versions

Affects versions

Priority

PagerDuty

Created January 17, 2007 at 4:48 PM
Updated January 27, 2017 at 4:32 PM
Resolved August 12, 2011 at 9:59 AM

Flag notifications