What is MagicDNS?
MagicDNS automatically creates DNS records for all devices in your network:- Access devices by hostname:
ssh myserverinstead ofssh 100.64.0.10 - Full domain names:
myserver.headscale.net - Works across all devices in your network
- No manual DNS configuration needed
MagicDNS Configuration
MagicDNS is configured inconfig/config.yaml:
config/config.yaml
Configuration Options
| Option | Description | Example |
|---|---|---|
magic_dns | Enable/disable MagicDNS | true or false |
base_domain | Domain suffix for devices | headscale.net or example.com |
nameservers.global | Upstream DNS servers | ["1.1.1.1", "8.8.8.8"] |
Change Base Domain
Using MagicDNS
Once enabled, access devices by hostname:- SSH
- HTTP/HTTPS
- Ping
- Database
Custom DNS Records
Add custom DNS records for non-Tailscale devices:config/config.yaml
Split DNS
Route specific domains through your Tailscale network:config/config.yaml
Split DNS Use Cases
Internal Services
Route company domain queries to internal DNS:
Home Lab
Resolve home lab domains:
Multiple Locations
Different DNS servers per location:
Development
Route dev domains to dev DNS:
Custom Nameservers
Global Nameservers
Used for all DNS queries not handled by MagicDNS:- Cloudflare
- Google
- Quad9
- Local DNS
config/config.yaml
DNS Over HTTPS (DoH)
For enhanced privacy, use DNS over HTTPS:config/config.yaml
Hostname Management
Set Custom Hostname
When connecting a device:my-custom-namemy-custom-name.headscale.net
Change Hostname
Hostname Conflicts
If multiple devices have the same hostname, use full domain:Testing DNS Resolution
Verify MagicDNS is Working
Check DNS Configuration
DNS in Docker Containers
When running Tailscale in Docker, DNS may need special configuration:docker-compose.yml
Advanced DNS Configuration
DNS Search Domains
Add search domains for shorter names:config/config.yaml
Per-User DNS Settings
Use ACL policies to control DNS access:config/policy.json
Troubleshooting
MagicDNS Not Working
DNS Resolution Slow
config/config.yaml
Cannot Resolve Hostnames
Split DNS Not Working
Best Practices
Use Descriptive Hostnames
Document DNS Records
Keep a list of custom DNS records:
Use Reliable DNS Servers
Choose fast, reliable upstream DNS:
Test Before Production
Test MagicDNS thoroughly:
