How do I health check DNS servers?
Short answer
A Health Checks profile is created with Check Type set to DNS: a name that the server must answer is written in the Query field and DNS Record Type is selected (default A). With Answer Check Mode, a specific text (Text Match (Contains)) or a regular expression (Regex Match) can be searched for in the answer; with the default None, receiving an answer is sufficient. For the Backend Service whose address is the DNS server's IP and port 53, the profile is selected in the Health Check field. The same settings are made in WEB-CLI with the lb hc add command by writing checkType dns.
Problem: The DNS Server Is Up but Does Not Respond Correctly
Port 53 of a DNS server being open does not mean that it responds correctly: the zone may not be loaded, recursive resolution may be broken, or a wrong record may be returned. If only a port check is performed, the server that responds incorrectly continues to receive traffic. The health check needs to send a real query and verify the answer.
Solution: 2 Methods
The two methods create the same profile from different interfaces.
| Your situation | Suitable method |
|---|---|
| I create the profile from the interface | Method 1: DNS profile |
| I create the profile from WEB-CLI | Method 2: WEB-CLI |
Method 1: DNS Profile Recommended
- How it works The specified query is sent to the address and port of the Backend Service; if no answer can be received, if the name cannot be found (NXDOMAIN), or if the expected text or pattern is not in the answer, the check fails.
- Where it is openedLoad Balancer → Profiles → Health Checks → Add → Check Type: DNS
- Requirement The queried name must be resolvable on this server; a Backend Service whose address is the DNS server's IP and port 53
- vService type All; if DNS traffic is to be balanced over UDP, a Network vService (UDP - L4) is used, and the health status is reflected in distribution while Port Range is off
Step-by-Step Configuration
The Configuration Menu is opened with the TR7 logo at the bottom left; the Load Balancer → Profiles → Health Checks path is followed and Add is clicked (How to add?).
The profile name is written in the Name field; in the Check Type field, DNS is selected. The type cannot be changed after saving.
The name to be queried is written in the Query field (e.g. portal.example.com); the record type is selected from the DNS Record Type list: A (default), AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SRV, TXT. For a reverse query, Reverse DNS (PTR) is turned on and an IP is written in the Query field; in this case, the record type field is hidden.
In the Answer Check Mode field, Text Match (Contains) is selected and the expected value (e.g. 192.0.2.21) is written in the Expected Answer Text field; if an exact match is required, Regex Match is selected and the pattern (e.g. "192\.0\.2\.21") is written in the Expected Answer Regex field. With the default None, receiving an answer is sufficient.
The Add button is clicked.
The Load Balancer → Backend Services path is followed; the Backend Service whose address is the DNS server's IP and port 53 is right-clicked and Edit is selected.
The DNS profile is selected in the Health Check field.
The Edit button is clicked. In a cluster, the change is transferred to the peer device automatically by default; if Manual Sync Mode is on, it is sent with Synchronize.
Verification
The DNS Answers row in the Details tab of the preview shows the answer received in the last check (Details rows).
DNS Answers: 192.0.2.21 · OK (green)In the Health Checks tab in the preview, the record summary contains the check type, the duration and the DNS answers; a new record is written when the answer changes.
OK · DNS / 2ms / 192.0.2.21Method 2: WEB-CLI
- How it works The DNS profile is created with the
lb hc addcommand by writingcheckType dnsand is assigned to the Backend Service withlb backend update;queryis required in the dns type,dnsTextToExpectbecomes required when--dnsExpectType textis written, and both are written without a prefix. - Where it is opened WEB-CLI →
lb hc add·lb backend update(lb hc · The DNS Fields) - Requirement WEB-CLI access; the Backend Service ID (
lb backend list) - vService type All
Step-by-Step Configuration
lb hc add checkType dns name dns-denetimi query portal.example.com --rrType A --dnsExpectType text dnsTextToExpect 192.0.2.21The profile ID is taken from the lb hc list output:
lb backend update id <backend-id> --hc <profile-id>Verification
The indicator in the Health column of the Backend Services list is checked (Health status indicator).
OK (green)Common Mistakes
- Overlooking partial matches. Text Match (Contains) searches within the answer; a search for
192.0.2.2also matches the answer192.0.2.21. For an exact match, the value is written with its quotes in Regex Match ("192\.0\.2\.21"); answers are compared in the["192.0.2.21"]form, and Regex Match is case-insensitive. - Querying a name the server cannot resolve. The name must be in a zone for which the server is authoritative, or the server must perform recursive resolution for TR7's source address.
- Leaving the Backend Service port other than 53. The query goes to the port of the Backend Service.
- Settling for a port check only. A UDP or TCP port check does not show that the DNS service responds correctly.
How it is done in the documentation
