To allow Home Assistant (running in network_mode: host) to communicate with addon containers in a custom bridge network, a DNS proxy is required. This setup uses an Nginx container to proxy DNS requests to the Docker internal resolver.
1. Define the custom network in docker-compose.yml
Use a specific subnet to ensure predictable IP addressing for the DNS proxy and Home Assistant's DNS settings.
2. Configure the DNS Proxy container
The dns service uses an Nginx image with a stream configuration to proxy UDP port 53 traffic to 127.0.0.11:53 (the Docker internal DNS).
3. Configure Home Assistant DNS
Set the dns option in the homeassistant service to point to the IP address of your dns container (e.g., 172.30.32.3).
# docker-compose.yml network snippet
networks:
default:
driver: bridge
driver_opts:
com.docker.network.bridge.name: hassio
ipam:
config:
- subnet: 172.30.32.0/23
ip_range: 172.30.33.0/24
gateway: 172.30.32.1
# dns_proxy.conf snippet
stream {
server {
listen 53 udp;
proxy_pass 127.0.0.11:53;
proxy_timeout 10s;
}
}