Cloud auto join using mDNS

Hi,

I’m trying to connect to the Consul server using mDNS provider in cloud auto-join. For mDNS, I’ve install avahi on both server and client. On client, I’m able to ping consul.local. However, the Consul agent seems to be unable to find the server.

I couldn’t find examples to get this to work. Will someone point me in the right direction?

Thanks.

This is the log.

: ==> Consul agent running!
:     2020-05-22T01:27:56.941Z [INFO]  agent: Retry join is supported for the following discovery methods: cluster=LAN discovery_methods="aliyun aws azure digitalocean gce k8s linode mdns os packet scaleway softlayer tencentcloud triton vsphere"
:  agent: Retry join is supported for the following discovery methods: cluster=LAN discovery_methods="aliyun aws azure digitalocean gce k8s linode mdns os packet scaleway softlayer tencentcloud triton vsphere"
:     2020-05-22T01:27:56.941Z [INFO]  agent: Joining cluster...: cluster=LAN
:  agent: Joining cluster...: cluster=LAN
:     2020-05-22T01:27:56.942Z [DEBUG] agent: discover: Using provider "mdns": cluster=LAN
: agent: discover: Using provider "mdns": cluster=LAN
:     2020-05-22T01:27:56.941Z [WARN]  agent.client.manager: No servers available
:     2020-05-22T01:27:56.942Z [ERROR] agent.anti_entropy: failed to sync remote state: error="No known Consul servers"
:  agent.client.manager: No servers available
: agent.anti_entropy: failed to sync remote state: error="No known Consul servers"

This is the client agent configuration.

{
    "datacenter": "dc1",
    "data_dir": "/var/lib/consul",
    "bind_addr": "{{ GetPrivateInterfaces | include \"network\" \"192.168.5.0/24\" | attr \"address\" }}",
    "client_addr": "0.0.0.0",
    "advertise_addr": "{{ GetPrivateInterfaces | include \"network\" \"192.168.5.0/24\" | attr \"address\" }}",
    "log_level": "DEBUG",
    "enable_syslog": true,
    "acl_enforce_version_8": false,
    "retry_join": [
        "provider=mdns service=consul v6=false"
    ]
}

Might be easier to help if you post your avahi config?

Using mDNS for auto-join requires some additional work in Consul to support.

Please :+1: the issue to express your interest for this feature.

@blake over the weekend, I found this: https://github.com/hashicorp/consul/blob/master/vendor/github.com/hashicorp/go-discover/provider/mdns/mdns_provider.go

It appeared to work? What else needs to be completed?

@MikeZ,

The issue I linked references the changes needed.

This issue is to track adding an mDNS responder to Consul to allow returning the Consul instances advertise address when queried. The responder + using the go-discover provider with retry-join would allow auto-clustering of all instances on a local network without having to know any of the IPs ahead of time.

Consul needs an mDNS responder, in addition to the go-discover support.

Ah I see, thanks for the clarification! I wrote a quick client over top of mdns and have it working. It would be nice to have it fully completed in Consul/Nomad as this is a change we would also want. Sorry to derail this!

1 Like

I, too, thought is was ready since mdns provider was supported. Thanks for the clarification. I’ll :+1: to support the issue.