Consul will not resolve DNS names on ubuntu 18.04

I’m trying to setup a consul + nomad cluster on ubuntu 18.04. Attempting to use the systemd-resolvd setup method as documented here

/etc/systemd/resolved.conf

[Resolve]
DNS=127.0.0.1
Domains=~consul
service systemd-resolved restart

iptables are configured

iptables -t nat -A OUTPUT -d localhost -p udp -m udp --dport 53 -j REDIRECT --to-ports 8600
iptables -t nat -A OUTPUT -d localhost -p tcp -m tcp --dport 53 -j REDIRECT --to-ports 8600
iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             localhost.localdomain  tcp dpt:domain redir ports 8600
REDIRECT   udp  --  anywhere             localhost.localdomain  udp dpt:domain redir ports 8600

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination

I’ve ensured that consul port 8600 is listening on 127.0.0.1 and not the public ip

netstat -plnt | grep consul
tcp        0      0 10.47.80.7:8301         0.0.0.0:*               LISTEN      21245/consul
tcp        0      0 127.0.0.1:8500          0.0.0.0:*               LISTEN      21245/consul
tcp        0      0 127.0.0.1:8600          0.0.0.0:*               LISTEN      21245/consul

Yet I’m still not able to resolve .consul domains automatically

host foobar.service.consul
Host foobar.service.consul not found: 3(NXDOMAIN)
ping foobar.service.consul
ping: foobar.service.consul: Name or service not known
dig foobar.service.consul
# no results

Whereas these requests do work

dig @127.0.0.1 foobar.service.consul
# works
dig @127.0.0.1 -p 8600 foobar.service.consul
# works

Consul is configured as minimally as possible

{
  "acl": {
    "default_policy": "deny",
    "enable_token_persistence": true,
    "enabled": true
  },
  "bind_addr": "10.x.x.x",
  "data_dir": "/opt/consul",
  "datacenter": "foobar",
  "log_level": "INFO",
  "primary_datacenter": "",
  "retry_join": [
    "10.x.x.x",
    "10.x.x.x",
    "10.x.x.x"
  ],
  "server": false,
  "ui": false
}

What am I missing? How can I get consul to work on ubuntu 18.04?

We’ve had nothing but trouble with systemd-resolved and ripped that sucker out

How do you get consul working on 18.04? I’ve tried ‘bind’, ‘unbound’ and ‘dnsmasq’ in addition to ‘systemd-resolvd’ with no luck.

@spuder the answer to your question is here:

Long story short, bind your client to 0.0.0.0