Page tree

Summary: this page describes how to configure Nodes with multiple active network interfaces and therefore multiple IP addresses to register with the Console service registry using a hostname instead of an IP address.

This information is valid only for Console ≥ 2.x when using Enterprise mode.

Introduction

Out of the box, Nodes are configured to register themselves with the Console service registry using an IP address: this ensures that the Node can be reached at all times. However, sometimes a Node may have more than one active network interface and therefore more than one assigned IP address at any one time. In this situation, the Node will register itself with the Console gateway using one of the active IP addresses at random. This situation will usually work fine, however, if the Node has registered itself with one of its network interfaces/IP addresses that subsequently changes or is disabled, then communication between Console and the Node will fail and the Node will be marked as unavailable in the Administration Center - Nodes panel. To resolve this situation, there are two options as detailed below.

You can perform the actions described in this document at any time - regardless of whether applications have been onboarded or whether the Node has been registered already.

Option 1 - Force Node to register using its hostname in application-default.yml

To force the Node to register itself using its hostname rather than its IP address, on each Node where you want to make this change, locate and edit the following properties file:

Enterprise mode: %PROGRAMDATA%\CAST\AIP-Node\application-default.yml

Add the line preferIpAddress: false into the file, under eureka: instance: as follows:

eureka:
  instance:
    # This instanceId will be used as a node name, it should be unique
    instanceId: ${spring.cloud.client.hostname}:${server.port}
	preferIpAddress: false

Save the application-default.yml file and then restart the Node. The Node will then register itself using its hostname, rather than the IP address.

Option 2 - Set advanced networking options in application-default.yml where hostname cannot be used

If you cannot use the Node's hostname (for example the hostname does not resolve across your network) then you can alternatively use some advanced Spring.io networking configuration options to the application-default.yml file as listed below (see also https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/appendix.html):

OptionDefault settingDescription

spring.cloud.inetutils.default-hostname

localhost

The default hostname. Used in case of errors.

spring.cloud.inetutils.default-ip-address

127.0.0.1

The default IP address. Used in case of errors.

spring.cloud.inetutils.ignored-interfaces

-

List of Java regular expressions for network interfaces that will be ignored. For example where the Node has multiple network interface adapters, each with a different name, you can list the names of the interfaces to be ignored.

spring.cloud.inetutils.preferred-networks

-

List of Java regular expressions for network address subnets that will be preferred. For example where the Node has multiple network interface adapters, each using a different subnet, you can list the subnets in order, or just one to force the use of that specific subnet.

spring.cloud.inetutils.timeout-seconds

1

Timeout, in seconds, for calculating hostname.

spring.cloud.inetutils.use-only-site-local-interfaces

false

Whether to use only interfaces with site local addresses. See {@link InetAddress#isSiteLocalAddress()} for more details.

When using the advanced networking configuration options, the option preferIpAddress: described in Option 1 above should always be set to true, or omitted from the file entirely (which leaves it in the true state).

On each Node where you want to make these changes, locate and edit the following properties file:

Enterprise mode: %PROGRAMDATA%\CAST\AIP-Node\application-default.yml

Then add in the required changes under spring: :cloud: inetutils: as shown in the examples below. When complete, save the application-default.yml file and then restart the Node. The Node will then use the advanced Spring.io networking configuration options.

Example 1

In the following example, the preferred-networks option has been added to force the Node to always advertise itself to the Console service registry with an IP address that matches the network address listed (in this example, only IP addresses matching the 192.168.x.x subnet will be used):

spring:
  cloud:
    inetutils:
	  preferred-networks:
		- 192.168
  config:
    import: configserver:http://192.168.200.107:8088/config

Example 2

In the following example, the default-hostname and the ignored-interfaces options have been added to force a specific hostname and to ignore network interfaces that match the ones in the list:

spring:
  cloud:
    inetutils:
      default-hostname: myaipnode.hostname.dev
      ignored-interfaces:
        - eth0
        - loopback*
  config:
    import: configserver:http://192.168.200.107:8088/config
  • No labels