Consul client and docker wont start due to ip config

I can get clients started that don’t have docker installed, however on the docker nodes I am un able to get them to start. The first error I got was there us multiple private networks… blah blah… So I edited the config to use the interface name as suggested in discussions. Now I get this error.

Any advise would be greatly appreciated.

Brad

So here is my config. This shows the client.

# Consul Config for Client
# ------------------------

datacenter = "nyc"
data_dir = "/opt/consul"
client_addr = [ "127.0.0.1 {{ GetInterfaceIP 'enp6s0' }}" ]
ui_config{
  enabled = true
}

bind_addr = "0.0.0.0"
advertise_addr = "{{ GetInterfaceIP 'enp6s0' }}"
server = false

encrypt = "ZH1+mvksSghQ="
retry_join = ["10.1.96.3 10.1.96.4 10.1.96.5"]

# metrics config
telemetry {
  prometheus_retention_time = "30s"
  disable_hostname = true
}

Here is my interface list.

 IPv4 address for docker0:    172.17.0.1
  IPv4 address for enp1s0:     1.1.1.1
  IPv4 address for enp6s0:     10.1.96.7
  IPv4 address for tailscale0: 1.1.1.1

Here is the error I get when trying to start the service.

Aug 01 09:59:35 www1 consul[18591]: ==> Multiple private IPv4 addresses found. Please configure one with 'bind' and/or 'advertise'.

Hi @bradley,

The -bind/bind_addr is the actual address that Consul will listen on when starting.`

The -advertise/advertise_addr is the address that Consul will advertise to other nodes in the cluster. It defaults to the value of bind_addr. It can be used when the bind_addr is not directly accessible from other hosts in the cluster.

Try just explicitly specifying bind_addr in your config, and omit advertise_addr.

bind_addr = "{{ GetInterfaceIP 'enp6s0' }}"

This is the ONLY configuration that was able to make work. What an ordeal to just get the right ip addresses to work.

# Consul Config for Server
# ------------------------

datacenter = "nyc"
data_dir = "/opt/consul"
client_addr = "0.0.0.0"
ui_config{
  enabled = true
}

bind_addr = "0.0.0.0"
advertise_addr = "10.1.96.3"

server = true
bootstrap_expect=3

encrypt = "ZH1+mvksSTeV"
retry_join = ["10.1.96.3 10.1.96.4 10.1.96.5"]


# metrics config
telemetry {
  prometheus_retention_time = "30s"
  disable_hostname = true
}

Hi @bradley,

I apologize you experienced so much frustration in trying to get this to work.

Is there anything you feel we should add to the docs for -advertise/advertise_addr and -bind/bind_addr in order to make them easier to understand for others who are also looking to use these options?

I know this is an old thread, but I had the same issue and I found a solution. Unfortunatelly @blake your solution is incorrect. Template library does not support single quotes:

user@hostname:~/go/bin$ ./sockaddr eval "GetInterfaceIP 'eth0'" 
ERROR[0] in: "{{GetInterfaceIP 'eth0'}}"
[0] msg: unable to parse template "{{GetInterfaceIP 'eth0'}}": template: sockaddr.Parse:1: malformed character constant: 'eth0'

It only supports double quotes:

user@hostname:~/go/bin$ ./sockaddr eval 'GetInterfaceIP "eth0"'
192.168.2.221

So .hcl file will look like this:

bind_addr = "{{ GetInterfaceIP \"eth0\" }}"