Views (split horizon)¶
A view is a named, tenant-scoped client ACL. Services and static DNS records opt into a view; a row with no view is in the default set and is visible to every client. One name can therefore answer differently depending on who asked — the classic "internal clients get the private address, everyone else gets the public one" — without running a second nameserver.
Tier: pro (views). Permissions: view:read / view:write (admin and
operator get both, viewer reads).
The rule, in one paragraph¶
For a query at
namefor typeTfrom clientC: the visible rows at(name, T)are those whose viewCmatches, plus those with no view. If any visible row belongs to a matched view, the rows of the highest-priority matched view that has data at(name, T)are the answer; otherwise the default rows are. A name exists forCif it has any visible row of any type. Wildcard services follow RFC 4592 on top of this: the exact name is consulted first, and a wildcard only when the exact name has no visible data.
Consequences worth knowing before you design a zone around it:
- A view shadows per RRset and layers over the default set. Overriding the
internal
Aforwwwdoes not hide its defaultMX. - A name that exists only in a view is NXDOMAIN outside it. That is intended.
- A name in the default set exists for everyone; there is no tombstone.
To express "external clients only", make external a real view
(
0.0.0.0/0,::/0, lowest priority) and put the external-only names there, leaving in the default set what both audiences share. - Two views may overlap.
prioritydecides — explicitly, not by prefix length. - A client matching no view gets the default set. A matching failure can never turn a live name into NXDOMAIN.
Matching a client¶
A client matches when its address is inside any matchCidrs entry or its
resolved region name is in matchRegions (the tenant's own regions — see
Regions). Either list may be empty; at least one must be
non-empty, or the view could never match anything.
The address matched is the transport source. Set trustEcs to match the
EDNS Client Subnet address instead when the query carries one. The default is
off on purpose: ECS is supplied by the client's resolver and can be forged, so
an "internal only" view must not be steerable from outside. Turn it on for the
other use of views — different public record sets per continent — where the
recursive resolver's own location is the wrong signal.
A row pointing at a deleted view is invisible, not default: deleting a view is refused while anything still references it, so this only happens if rows are restored out of band.
Data model¶
views is a table of its own; services.view_id and dns_records.view_id
(empty = default set) reference it by ID with no foreign key — SQLite only
allows ADD COLUMN ... REFERENCES with a NULL default, and NULLs are distinct
in a unique index, which would let two default-set services share a domain.
Deletion is refused by the API instead, with the usage count in the 409.
The unique index on services is (lower(rtrim(domain,'.')), view_id): one
service per domain per view. services.name stays globally unique, so a
per-view service needs its own name — www-internal beside www.
v1 limits¶
These are deliberate scope lines, not bugs:
| Area | v1 behaviour |
|---|---|
| Identical records across views | dns_records still carries UNIQUE(name, type, value), so a byte-identical RR lives in exactly one view. Shadowing makes duplicating one unnecessary. Relaxing it needs a table rebuild, which waits on versioned migrations. |
| TXT records | The legacy dns_txt_records table (ACME DNS-01, RFC 2136 UPDATE targets) is view-blind. |
| Secondary zones | A zone slaved by AXFR-in is served exactly as the primary sent it: no views. |
| AXFR-out | A transfer carries the default set only; per-view services and records are skipped. Serving a transferring secondary the set it would be answered is the correct end state, but it changes what existing secondaries receive. |
| Zone sync (Cloudflare/Route 53/Bunny) | Pushes the default set. |
| Query tracer / simulate | Traces a service by ID, which already identifies the per-view row. It does not yet report which views a client would match. |
| Terraform | No nexus_view resource yet; view_id is not yet an attribute on nexus_service / nexus_record. |
| ASN-based ACLs | Not available; use CIDRs or regions. |
DNSSEC¶
Signed zones may carry views, and nothing is disabled. Signing is online, an
RRSIG covers one RRset, and two clients receiving different www A RRsets each
get a valid signature under the same zone keys — which is what geo steering
already produces today. The one invariant: a denial proof is built from the
same view as the answer, so the NSEC3 bitmap asserts the types that
client can see. DNSKEY, CDS, SOA and NS are zone-level and view-blind.
Not affected by views¶
RPZ rules, referrals and glue, DNAME, response-rate limiting, sticky routing, RUM, insights, the traffic map, and the SOA/NS of a zone. A firewall rule and a delegation apply to everyone.
Steering is unchanged and runs inside the chosen row: the view picks which service answers, and that service's own filter chain, schedules, shadow pool, weight feeds and rollouts then run exactly as they do without views. A per-view service is an ordinary service in every other respect.
Performance¶
The view set is an in-memory snapshot rebuilt every 5s (and immediately on the
node that served a write) — the same shape as the region engine. Matching is a
map lookup plus a handful of Contains calls, memoised per query. No extra DB
read: the service lookup already fetched every row at the name, and record
lookups already returned every row at the name.
When no row carries a view the whole mechanism short-circuits: identical answers, one string compare per row. A cluster that never creates a view pays nothing and needs no migration — every existing row is already in the default set.
API¶
| Method | Path | Notes |
|---|---|---|
GET |
/api/v1/views |
Priority-desc, each with a usage count |
POST |
/api/v1/views |
pro license |
GET |
/api/v1/views/{id} |
|
PUT |
/api/v1/views/{id} |
Replaces the ACL fields wholesale |
DELETE |
/api/v1/views/{id} |
409 while any service or record references it |
viewId is an optional field on service and static-record create/update, and
is returned on both.
gslbctl¶
gslbctl views list
gslbctl views create internal --cidr 10.0.0.0/8,192.168.0.0/16 --priority 10
gslbctl views update <id> --name internal --cidr 10.0.0.0/8 --trust-ecs
gslbctl views delete <id>
gslbctl services create --name www-internal --domain www.example.com --pool <id> --view internal
gslbctl records create --name www.example.com. --type A --value 10.0.0.5 --view internal
gslbctl records update <id> --view default # back to the default set
Upgrade and rollback¶
Both columns default to '', so every existing row is in the default set and
an upgrade changes no answer. The unique index is swapped in place, keeping its
name, so rolling back to the previous binary still starts — but that binary
knows nothing about views: if per-view services exist it will answer one of the
rows at a shared domain arbitrarily until the new binary returns. Delete the
per-view rows before a planned rollback if that matters.