Traefik v2.2 DNS service UDP howto

Thanks for the new release supporting UDP services as well. I was able to build a containerized DNS service with Traefik as Frontend load balancing to pariticpating nodes.

The setup is as follows:

  • docker plain, no Orchestration tool as too complex for simple deployments
  • container labels for assignment of services

Considerations and requirements:

  • People need to be aware of, queries comming in will always be masqueraded, meaning no views, no ACLs on restricting or limit or similar. So dont put a resolving DNS public available with this howto as you'll be resolving for everyone.
  • People need to be aware of, queries coming in might be TCP based and not only UDP so make sure you do the TCP router setup as well.

Traefik configuration with Entrypoints definition as those can't go with container labels.

entryPoints:
  ... 
  dnstcp:
    address: ":53"
  dnsudp:
    address: ":53/udp"

Labels applied to each container participating in the service:

traefik.enable=true
traefik.udp.routers.dnsudp.entrypoints=dnsudp
traefik.udp.services.dnsudp.loadbalancer.server.port=53
traefik.tcp.routers.dnstcp.entrypoints=dnstcp
traefik.tcp.routers.dnstcp.rule=HostSNI(`*`)
traefik.tcp.services.dnstcp.loadbalancer.server.port=53
1 Like