Point clients at the DNS servers
The DNS servers that run with the agent are authoritative only: they answer for the zones of your Valgrid namespace and refuse every other name. Do not make them your clients' only DNS servers. Instead, keep clients on their usual resolvers, and tell those resolvers to send queries for your internal zones to the DNS servers.
The examples below use the zone corp.internal and two DNS servers,
192.0.2.53 and 192.0.2.54. Repeat the configuration for each zone you
serve, or configure a common parent zone once. List at least two DNS servers so
that one can be upgraded or restarted while the other answers.
Two settings come up for most resolvers:
- DNSSEC validation. Valgrid zones are not signed. A resolver that
validates DNSSEC sees that a name such as
corp.internaldoes not exist in public DNS and rejects the answers, so mark the zone as insecure (also called a negative trust anchor) where the examples show it. - Rebinding protection. Resolvers that drop answers with private addresses must be told that the zone may contain them.
BIND
Add a forward zone to named.conf (on Debian and Ubuntu,
/etc/bind/named.conf.local), and add validate-except to the existing
options block:
options {
// ...your existing options...
validate-except { "corp.internal"; };
};
zone "corp.internal" {
type forward;
forward only;
forwarders { 192.0.2.53; 192.0.2.54; };
};
forward only stops BIND from falling back to public DNS when the DNS servers
cannot be reached. Apply the change with rndc reconfig.
Unbound
Add a stub zone to unbound.conf, or as a file in /etc/unbound/unbound.conf.d/.
A stub zone fits authoritative servers, which do not answer recursive queries:
server:
domain-insecure: "corp.internal"
# Needed only when you use private-address: for rebinding protection.
private-domain: "corp.internal"
stub-zone:
name: "corp.internal"
stub-addr: 192.0.2.53
stub-addr: 192.0.2.54
Check the file with unbound-checkconf and apply it with
unbound-control reload.
dnsmasq
Add the zone to /etc/dnsmasq.conf, or as a file in /etc/dnsmasq.d/:
server=/corp.internal/192.0.2.53
server=/corp.internal/192.0.2.54
# Needed only when stop-dns-rebind is set.
rebind-domain-ok=/corp.internal/
Restart dnsmasq to apply it. The same lines work on routers and appliances that use dnsmasq, such as OpenWrt and Pi-hole, often through a "conditional forwarding" or "custom dnsmasq" setting.
CoreDNS
Add a server block for the zone to the Corefile of the CoreDNS that your clients use:
corp.internal {
forward . 192.0.2.53 192.0.2.54
cache 30
errors
}
CoreDNS sends queries to the most specific matching block, so other names keep
using your existing . block. With the reload plugin the change is applied
without a restart.
Kubernetes cluster DNS
To resolve the zones from pods, add the same block to the cluster's CoreDNS
configuration, the coredns ConfigMap in the kube-system namespace:
kubectl -n kube-system edit configmap coredns
Use addresses CoreDNS can reach. When the DNS servers run in the same cluster,
use the cluster IP of their Service, because forward takes addresses, not
names:
kubectl -n valgrid-dns get service valgrid-dns -o jsonpath='{.spec.clusterIP}'
Managed Kubernetes services may have their own way to add forwarding rules, such as a separate custom ConfigMap; follow your provider's documentation.
Windows DNS Server
Create a conditional forwarder. In PowerShell:
Add-DnsServerConditionalForwarderZone -Name "corp.internal" `
-MasterServers 192.0.2.53, 192.0.2.54 `
-ReplicationScope "Forest"
-ReplicationScope stores the forwarder in Active Directory so that every
domain controller in the forest uses it. Leave it out on a DNS server that is
not a domain controller. In DNS Manager, the same setting is under
Conditional Forwarders > New Conditional Forwarder.
systemd-resolved
systemd-resolved sends a query to the DNS servers whose routing domain matches
the name. A routing domain is written with a leading ~, such as
~corp.internal, so that it is not also used as a search domain.
DNS delegate (systemd 258 and later)
Save this as /etc/systemd/dns-delegate.d/valgrid.dns-delegate:
[Delegate]
DNS=192.0.2.53 192.0.2.54
Domains=corp.internal
Apply it with sudo systemctl restart systemd-resolved. Only queries for
corp.internal and names below it go to these servers.
Global drop-in
On older versions, add a drop-in, such as
/etc/systemd/resolved.conf.d/valgrid.conf:
[Resolve]
DNS=192.0.2.53 192.0.2.54
Domains=~corp.internal
Apply it with sudo systemctl restart systemd-resolved. Queries for
corp.internal go to these servers. systemd-resolved can also send other
queries to the global servers; they refuse them and the answer comes from your
other DNS servers. Use a DNS delegate instead where your systemd version has
it.
Per network interface
To tie the setting to one network interface, such as a VPN, set it on that interface. systemd-resolved sends the zone's queries to any of that interface's DNS servers, so use an interface whose only DNS servers are the Valgrid DNS servers. With NetworkManager:
nmcli connection modify "<connection>" \
ipv4.dns "192.0.2.53 192.0.2.54" \
ipv4.dns-search "~corp.internal"
nmcli connection up "<connection>"
With systemd-networkd, in the interface's .network file:
[Network]
DNS=192.0.2.53
DNS=192.0.2.54
Domains=~corp.internal
For a quick test that is lost on reboot:
sudo resolvectl dns <interface> 192.0.2.53 192.0.2.54
sudo resolvectl domain <interface> '~corp.internal'
Check the result with resolvectl status and
resolvectl query localhost.corp.internal.
Check from a client
From a client, query a record through its usual resolver:
dig localhost.corp.internal A +short
It prints 127.0.0.1. If it does not, query the DNS server directly, as in
Verify, to tell a resolver problem from a DNS server
problem.