> ## Documentation Index
> Fetch the complete documentation index at: https://bunny.net/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# bunny dns

> Manage DNS zones and records from the command line.

`bunny dns` manages [DNS](/docs/dns.md) through three resource groups:

* **`bunny dns records`** manages the entries within a zone.
* **`bunny dns zones`** manages the zone itself: settings, DNSSEC, logging, stats, and nameservers.
* **`bunny dns scripts`** manages [Scriptable DNS](/docs/dns/scriptable/introduction.md) scripts.

The `[domain]` argument accepts either the zone's domain name or its numeric zone ID, and is optional everywhere. Omit it and the CLI uses the zone linked with `bunny dns zones link`, or prompts you to pick one. `records update` and `records remove` likewise prompt you to pick a record when the ID is omitted.

`records` aliases to `record` / `rec`; `zones` aliases to `zone`; `scripts` aliases to `script`.

## Records

Manage the DNS records within a zone.

```bash theme={null}
# List records within a zone
bunny dns records list example.com
bunny dns rec ls example.com

# Add records (use '@' for the zone apex)
bunny dns records add example.com api A 198.51.100.1
bunny dns records add example.com '@' MX mail.example.com 10
bunny dns records add example.com '@' SRV 10 0 389 sip.example.com
bunny dns records add example.com '@' CAA '0 issue "letsencrypt.org"'

# Link a record to a pull zone or Edge Script
bunny dns records add example.com cdn PullZone --pull-zone 12345
bunny dns records add example.com fn Script --script 67890

# Interactive wizard: omit the record type (or all args) to be prompted
bunny dns records add
bunny dns records add example.com

# Update / remove a record by its ID
bunny dns records update example.com 123 --value 198.51.100.2 --ttl 3600
bunny dns records remove example.com 123

# Add a preset set of records (email providers, verification, ...)
bunny dns records preset list
bunny dns records preset google-workspace example.com
bunny dns records preset bluesky example.com --param did=did:plc:abc123

# Scan for a domain's existing records and import them
bunny dns records scan example.com

# Import / export a BIND zone file
bunny dns records import example.com ./zonefile.txt
bunny dns records export example.com                  # print to stdout
bunny dns records export example.com --file ./my.zone # write to a path
bunny dns records export example.com --save           # write to ./example.com.zone
```

### Record value ordering

Positional values for `records add` follow the record type:

| Type | Positional values |
| - | - |
| `A` / `AAAA` / `CNAME` / `TXT` / `NS` | `<value>` |
| `MX` | `<value> <priority>` |
| `SRV` | `<priority> <weight> <port> <target>` |
| `CAA` | `'<flags> <tag> "<value>"'` (single quoted string) |
| `PullZone` | none, pass `--pull-zone <id>` |
| `Script` | none, pass `--script <id>` |

Omit the record type (or all arguments) to run an interactive wizard that prompts for the zone, type, and per-type values.

## Zones

Manage zone lifecycle, directory linking, statistics, nameservers, DNSSEC, and query logging.

```bash theme={null}
# Lifecycle
bunny dns zones list
bunny dns zones create example.com
bunny dns zones show example.com
bunny dns zones delete example.com

# Query statistics (defaults to the last 30 days; text mode draws a bar chart)
bunny dns zones stats example.com
bunny dns zones stats example.com --from 2026-05-01 --to 2026-05-31

# Link this directory to a zone (writes .bunny/dns.json)
bunny dns zones link example.com
bunny dns zones unlink

# Check whether the zone is delegated to bunny.net
bunny dns zones nameservers example.com
bunny dns zones ns example.com

# DNSSEC: enable prints the DS record to register at your domain registrar
bunny dns zones dnssec enable example.com
bunny dns zones dnssec disable example.com

# DNS query logging: enable to start collecting logs (optionally anonymize IPs)
bunny dns zones logging enable example.com
bunny dns zones logging enable example.com --anonymize-ip --anonymization drop
bunny dns zones logging disable example.com
```

## Scripts

Manage [Scriptable DNS](/docs/dns/scriptable/introduction.md) scripts: code that computes a DNS answer at query time, such as geo routing, weighted or failover answers, and closest-region selection. These are separate from Edge Scripts (`bunny scripts`, a different runtime).

A script only affects DNS once it backs a `SCRIPT` record on a zone. Use `attach` to add that record from the script side.

```bash theme={null}
# Scaffold a project: entry file, tsconfig, and package.json with a devDep on
# @bunny.net/scriptable-dns-types for editor autocomplete
bunny dns scripts init                                 # interactive wizard
bunny dns scripts init geo-router --example geo --deploy

# Create a remote script without scaffolding
bunny dns scripts create geo-router

# Upload and publish
bunny dns scripts deploy                               # linked script's entry file
bunny dns scripts deploy handleQuery.js
bunny dns scripts deploy handleQuery.js 12345          # target a specific script
bunny dns scripts deploy --skip-publish                # stage without publishing

# Link the current directory to a script / list all scripts
bunny dns scripts link 12345
bunny dns scripts list

# Point a hostname at a script by adding a SCRIPT record
bunny dns scripts attach example.com api --script 12345
bunny dns scripts attach example.com '@'               # apex, using the linked script
```

Scripts resolve without an explicit ID in this order: explicit `[id]`, then `.bunny/dns-script.json` (written by `link` / `create` / `init`), then the interactive picker.

`init` starters via `--example`: `empty`, `geo`, `closest`, `weighted`, `failover`, `pullzone`. Pass `--deploy` to also create the script on bunny.net after scaffolding.

`attach` always confirms before writing the record, and attaching at the apex (`'@'`) prints a stronger warning listing any records already at that name.

## Flags

| Flag | Commands | Description |
| - | - | - |
| `--ttl` | `records add`, `records update` | Time to live in seconds |
| `--comment` | `records add`, `records update` | Optional comment for the record |
| `--pull-zone`, `--script` | `records add`, `records update` | Link a `PullZone` / `Script` record by ID |
| `--name`, `--value`, `--type`, `--priority`, `--weight`, `--port`, `--flags`, `--tag`, `--disabled` | `records update` | Edit individual record fields (see `bunny dns records update --help`) |
| `--param` | `records preset` | Preset value as `key=value` (repeatable) |
| `--yes`, `-y` | `records scan` | Import without confirming |
| `--file`, `--save` | `records export` | Write to a path, or to `<domain>.zone` in the current directory |
| `--from`, `--to` | `zones stats` | Date range (defaults to the last 30 days) |
| `--anonymize-ip`, `--anonymization` | `zones logging enable` | Anonymize client IPs in logs (`onedigit` \| `drop`) |
| `--example`, `--deploy`, `--skip-install` | `scripts init` | Starter template, create on bunny.net, skip type dependency install |
| `--skip-publish` | `scripts deploy` | Stage the upload without publishing |
| `--script`, `--ttl` | `scripts attach` | DNS script ID (defaults to the linked script), record TTL |
| `--force` | `records remove`, `zones delete`, `zones dnssec disable`, `zones logging disable`, `scripts attach` | Skip the confirmation prompt |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.