Client Blocking — Refuse or Drop DNS by Origin¶
License: pro tier and above (
client-block). See Licensing.
Client block rules let a system admin declare origins unwelcome — by country, by ASN, or by CIDR — and have every node refuse or drop their DNS queries within about five seconds. Allow rules carve out exceptions, every rule counts its matches, and a dry-run mode counts without blocking so you can see what a rule would do before it does it. Rules are system-wide: they apply to every zone and every view identically.
This blocks resolvers, not people. The server only ever sees the address of the resolver that sent the query. A user in a blocked country using a public resolver abroad is still answered; a user anywhere who uses a resolver run by a blocked country's ISP is not. EDNS Client Subnet is deliberately ignored for blocking.
Rule fields¶
| Field | Meaning |
|---|---|
matchType |
country, asn or cidr. |
matchValue |
Canonical form is stored: an upper-case ISO 3166-1 alpha-2 code (RU); a bare AS number (12389, AS12389 is accepted on input); a masked prefix (203.0.113.0/24, a bare IP becomes /32 or /128). |
action |
allow, refuse or drop. |
mode |
enforce or dryrun. Dry-run counts matches but answers the query normally. Always enforce for allow rules. |
description |
Free text, at most 200 characters. |
hitCount |
Queries matched so far. |
matchType and matchValue cannot be changed after creation; delete and
recreate the rule. A /0 CIDR is refused for refuse and drop (it would
block every client).
Precedence¶
- Loopback (
127.0.0.0/8,::1) is always allowed and cannot be removed. - Any matching
allowrule wins over every block rule, whatever its type. - Otherwise the most specific block rule applies: the longest-prefix CIDR, then ASN, then country.
Private (RFC 1918 / ULA) space has no GeoIP country, so country rules never match it; a CIDR block over private space does apply, because you wrote it.
Responses¶
- refuse — a bare
REFUSED: authoritative bit clear, no EDNS OPT record, and empty answer, authority and additional sections. Nothing about your zones leaks. - drop — nothing is written on UDP, TCP and DoT, so the client times out.
DoH has no meaningful "no response", so a
droprule answersREFUSEDthere.
Where it applies¶
The check runs at the very top of the query handler, before the opcode dispatch, the licensed query-rate check and rate limiting.
| Path | Covered | Notes |
|---|---|---|
| UDP/TCP 53 | yes | |
| DNS over TLS | yes | |
| DNS over HTTPS | yes | The source is the HTTP peer address; api.trustedProxies is not applied, so behind a reverse proxy every client looks like the proxy. |
| RFC 2136 UPDATE | yes | |
| NOTIFY | yes | A NOTIFY from a primary inside a blocked range is refused — add an allow rule for your primaries. |
| AXFR / IXFR out | yes | Add an allow rule for your secondaries. |
| Outbound traffic (our AXFR-in, delegation checks, health probes, webhooks) | n/a | We are the client. |
REST API, WebUI, RUM beacon/ingest, /metrics |
no | HTTP, not DNS. Use a host firewall. |
Data sources¶
- Country comes from the GeoIP database already used for routing. With no database loaded, country rules never match.
- ASN comes from the database at
loadBalancer.asn.dbPath(the same file theasnrouting algorithm uses; there is no separate setting). Unset or unreadable, asn rules are stored but inactive.
Every lookup fails open: no database, an address not in the database, or a
lookup error means the rule does not match. GET /api/v1/client-block/rules
reports countryDatabase and asnDatabase; the WebUI shows a warning banner
and gslbctl client-block list prints a warning to stderr when one is missing.
Convergence¶
Each node holds the rule set in memory and reloads it from the replicated database every 5 seconds, so a change reaches every node within about five seconds. The node that took the write applies it immediately.
Observability¶
- Per-rule
hitCount, flushed from each node to the database every 5 seconds. - Metric
gslbd_client_block_matches_total{type,action,mode}— no address or value labels, to keep cardinality bounded. Dry-run matches are counted too (mode="dryrun"). - Enforced blocks (refused and dropped, not dry-run) appear in red on the Traffic Globe, per origin country, and as
dropped/refusedcounts inGET /api/v1/traffic/geo. These counters are in memory per node and reset at UTC midnight and on restart, like the rest of the globe. - One log line per rule per flush (rule id, type, value, action, mode, hits) when the rule matched in that interval. Individual queries are never logged.
API¶
System admin only (the default tenant's tenant_admin or the GSLB_API_KEY
holder) — a block affects every tenant, and the matched origins are sensitive.
Every change is audited like any other write.
| Method and path | Purpose | Success |
|---|---|---|
GET /api/v1/client-block/rules |
{rules, countryDatabase, asnDatabase} |
200 |
POST /api/v1/client-block/rules |
{matchType, matchValue, action, mode, description} |
201 |
PUT /api/v1/client-block/rules/{id} |
{action, mode, description} |
200 |
DELETE /api/v1/client-block/rules/{id} |
remove | 204 |
Errors: 400 invalid value, 403 not a system admin (or unlicensed, for create and
update), 404 unknown id, 409 duplicate (matchType, matchValue) or the
1000-rule limit (CIDR rules are scanned linearly). GET and DELETE are
never licence-gated, so a downgraded install can always see and remove what is
blocking. See [swagger.yaml.
gslbctl and Terraform¶
gslbctl client-block add --type country --value RU --action drop # dry-run
gslbctl client-block list
gslbctl client-block update <id> --enforce
gslbctl client-block remove <id>
resource "nexus_client_block_rule" "block_ru" {
match_type = "country"
match_value = "RU"
action = "drop"
mode = "enforce" # Terraform defaults to enforce; a plan is the review step
}
Limitations¶
- Not a security boundary. UDP source addresses can be spoofed.
- It blocks resolvers, not people (see the note at the top).
- GeoIP country and ASN data is approximate and goes stale.
- ECS is ignored on purpose; only the transport source is used.
- A host firewall (nftables or ufw with country sets) also covers the HTTP surfaces, at the cost of per-node manual setup.
- No continent rule type: a continent is a handful of country rules.