Commands · reference

vmlab dns

3 min read · 2026-09-02 · vmlab 0.9

vmlab dns prints the DNS zones the current lab's segments serve: every exact record, wildcard and sinkhole, in the order the resolver consults them. It is the thing to read when a guest cannot resolve a peer.

sh
vmlab dns [OPTIONS]
OptionMeaning
--jsonEmit the raw JSON instead of a table.
-h, --helpPrint help.

What it prints

The verb starts the lab daemon if none is running and asks it for the DNS table. Segments with no local zone, global segments and segments with dns { enabled = false }, serve nothing and are not listed; with no serving segment at all the verb prints `no segment in this lab serves DNS`.

Each serving segment gets a heading segment "<name>" — zone <suffix> and a table of NAME, IP and KIND. Exact records come first, sorted by name, with kind static for a record the lab file declares and dynamic for one a DHCP lease registered; then wildcards with kind wildcard; then sinkholes with - for the address and kind sinkhole/<mode>, since a sinkhole answers with nothing and NXDOMAIN and 0.0.0.0 fail differently in a guest. A zone with no rules prints (no records).

With --json the daemon's reply is printed verbatim as pretty JSON, an object with a segments array whose entries carry segment and a zone with suffix, records, wildcards and sinkholes.

Examples

sh
vmlab dns
sh
segment "corp" — zone vmlab.internal
  NAME                              IP          KIND
  client01.ad-lab.vmlab.internal    10.10.0.50  dynamic
  dc01.ad-lab.vmlab.internal        10.10.0.10  static
  *.corp.example                    10.10.0.10  wildcard
  *.telemetry.example.com           -           sinkhole/nxdomain

Feed the table to a script:

sh
vmlab dns --json | jq '.segments[].zone.records[]'

Exit status

Exit status is 0 when the table was printed. A lab directory that cannot be found, or a daemon that could not be started or answered with a failure, exits 1 (failed). Exit 5 (conflict) means the supervisor tracks a lab with this name from another directory. A usage error exits 2.