Overview
MagicDNS is Tailscale’s automatic DNS configuration feature that allows you to access devices and services on your tailnet using simple hostnames instead of IP addresses. When enabled, you can connect to services using names likeservice-name instead of 100.x.y.z.
Benefits of MagicDNS:
- Access services using memorable hostnames
- Automatic DNS updates when IPs change
- Split DNS support for accessing both tailnet and internet resources
- HTTPS certificate integration with Tailscale’s certificate authority
Enabling MagicDNS
Network-Wide Configuration
- Navigate to the Tailscale DNS settings
- Click “Enable MagicDNS”
- Optionally configure a custom domain suffix (e.g.,
tail1234.ts.net)
Per-Service Configuration
Once MagicDNS is enabled on your network, configure individual services to use it:TS_ACCEPT_DNS Configuration
TheTS_ACCEPT_DNS environment variable controls whether the Tailscale container accepts DNS configuration from your tailnet:
- The container uses MagicDNS for hostname resolution
- Services can be accessed via their Tailscale hostnames
- DNS queries are split between tailnet and internet domains
- The container uses the system’s default DNS
- Manual DNS configuration may be required
In the service template and exit node configurations,
TS_ACCEPT_DNS=true is commented out by default. Uncomment it when you want to use MagicDNS:Using MagicDNS with Services
Accessing Services by Hostname
Once configured, access your services using their hostname:HTTPS with MagicDNS
Combine MagicDNS with Tailscale’s HTTPS certificates for secure access:DNS Configuration Patterns
Pattern 1: MagicDNS Only
Use Tailscale’s DNS exclusively:Pattern 2: MagicDNS with Fallback
Use MagicDNS but specify custom DNS servers as fallback:The exit node example uses this pattern to ensure DNS resolution works even if MagicDNS is not configured.
Pattern 3: Custom DNS Only
Bypass MagicDNS and use specific DNS servers:Split DNS Configuration
Configure custom DNS resolvers for specific domains in your Tailscale admin console:Example: Internal Domain Resolution
- Go to DNS settings
- Under “Nameservers”, add a custom resolver:
- Domain:
internal.company.com - Nameserver:
100.64.1.10(your internal DNS server)
- Domain:
- Queries for
*.internal.company.comwill route to your internal DNS - All other queries use MagicDNS or public DNS
Docker Compose Integration
Troubleshooting
Hostnames Not Resolving
Check MagicDNS is enabled:DNS Resolution Conflicts
Problem: System DNS conflicts with Tailscale DNS Solution: Use thedns: section to explicitly set DNS servers:
Service-to-Service DNS
Problem: Containers can’t resolve each other’s MagicDNS names Solution: Ensure both containers haveTS_ACCEPT_DNS=true and are on the same tailnet:
DNS Leaks
When using exit nodes, verify DNS queries route through the exit node:Best Practices
Use descriptive hostnames
Use descriptive hostnames
Choose service hostnames that clearly identify their purpose:
plex-serverinstead ofserver1home-assistantinstead ofhamonitoring-grafanainstead ofgrafana
Enable MagicDNS globally
Enable MagicDNS globally
Enable MagicDNS at the network level rather than per-device for consistency across all services.
Document DNS configuration
Document DNS configuration
When using split DNS or custom resolvers, document the configuration in your service README:
Test DNS resolution
Test DNS resolution
Always test DNS resolution after deploying a service:
Examples from ScaleTail
Both the service template and exit node configurations include MagicDNS support as a commented option: From/source/services/tailscale-exit-node/compose.yaml:
/source/templates/service-template/compose.yaml:
Related Resources
Exit Nodes
Route traffic through your network
Custom Services
Create your own service configurations