Count - Count Number of Queries

Count - Count Number of Queries

PolarDNS internally tracks the number of times each domain name has been queried.

This feature allows clients to retrieve the query count for a specific domain name.

The module returns a TXT record containing the total number of queries received for the specified domain since the PolarDNS server was started.

Category: General features

Format

count.*

This module has no parameters.

Examples

The following examples demostrate the functionality of this module. We will use the basic always feature which always resolves to an IP address.

In this example, we want to meassure how many times the always12345.yourdomain.com domain has been queried so far. By prepending the count subdomain to the domain name, we retrieve the current query count:

# dig count.always12345.yourdomain.com @127.0.0.1

; <<>> DiG 9.20.7-1-Debian <<>> count.always12345.yourdomain.com @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23057
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;count.always12345.yourdomain.com. IN	A

;; ANSWER SECTION:
count.always12345.yourdomain.com. 60 IN	TXT	"0"

;; Query time: 4 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Fri Jun 20 15:00:11 +04 2025
;; MSG SIZE  rcvd: 64

Download PCAP File

We can see that at this point, the query count for the domain is 0. This means that this domain has never been queried.


Now, let’s query the domain. The response includes an IP address, as expected from the always feature. This query also internally increments the counter for the domain:

# dig always12345.yourdomain.com @127.0.0.1

; <<>> DiG 9.20.7-1-Debian <<>> always12345.yourdomain.com @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8943
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;always12345.yourdomain.com.	IN	A

;; ANSWER SECTION:
always12345.yourdomain.com. 60	IN	A	2.3.4.5

;; Query time: 4 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Fri Jun 20 15:00:13 +04 2025
;; MSG SIZE  rcvd: 60

Download PCAP File


Now, let's retrieve the query count again:

# dig count.always12345.yourdomain.com @127.0.0.1

; <<>> DiG 9.20.7-1-Debian <<>> count.always12345.yourdomain.com @127.0.0.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55790
;; flags: qr aa; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;count.always12345.yourdomain.com. IN	A

;; ANSWER SECTION:
count.always12345.yourdomain.com. 60 IN	TXT	"1"

;; Query time: 4 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Fri Jun 20 15:00:14 +04 2025
;; MSG SIZE  rcvd: 64

Download PCAP File

We can see that the query count for this domain has increased.

Using this feature, we can measure query count for any domain name.


From the same category


Go back to catalogue.