-
Notifications
You must be signed in to change notification settings - Fork 0
Custom DNS
By default, the container resolves names through NordVPN's own DNS servers (103.86.96.100 and 103.86.99.100), reached over the tunnel. These may apply regional filtering — for example, certain domains may be sinkholed when connected through some exit nodes.
Because the kill-switch firewall makes Docker's embedded resolver (127.0.0.11) unreachable, the container writes its own /etc/resolv.conf after the tunnel comes up. This page covers how to override the DNS servers it uses.
Set DNS to one or more servers (semicolon- or comma-separated). The container writes them to /etc/resolv.conf on every connect:
services:
vpn:
environment:
- DNS=1.1.1.1,1.0.0.1- Default (unset):
103.86.96.100;103.86.99.100(NordVPN). - The servers must be reachable through the tunnel (any public resolver is) or via a
NETWORKCIDR.
Mount a custom resolv.conf read-only. The container's attempt to rewrite it is rejected by the read-only mount (logged as a harmless warning), so your file stays in place:
1. Create a resolv.conf file:
nameserver 1.1.1.1
nameserver 1.0.0.1
2. Mount it in your compose file:
services:
vpn:
volumes:
- ./resolv.conf:/etc/resolv.conf:ro| Provider | Primary | Secondary |
|---|---|---|
| Cloudflare | 1.1.1.1 |
1.0.0.1 |
8.8.8.8 |
8.8.4.4 |
|
| Quad9 | 9.9.9.9 |
149.112.112.112 |
| OpenDNS | 208.67.222.222 |
208.67.220.220 |
Docker's dns: option configures an internal resolver (127.0.0.11) that forwards to the specified servers. In VPN containers with strict firewall rules (kill switch), Docker's internal DNS resolver is flushed/unreachable, resulting in connection refused errors. Use one of the methods above instead.
After the VPN connects, check which DNS servers are active:
docker exec vpn cat /etc/resolv.confTest resolution:
docker exec vpn nslookup example.comRun the full network diagnostic to see DNS details:
docker exec vpn /usr/local/bin/network-diagnosticThe diagnostic output includes a DNS configuration section showing the active nameservers and their geolocation.
Configuration
- Server Selection
- Server Groups
- IPv6 Configuration
- Automatic Reconnection
- Local Network Access
- VPN Gateway Mode
- Custom DNS
- Permissions
Security
Examples
Operations
Reference