Skip to content

akquinet/pdnsgrep

Repository files navigation

PDNS Grep

Search through PowerDNS records via API.

The wildcard * can be used as a placeholder in search_term and the ? character can be used as a placeholder for a single character.

Installation

Under Releases the binary can be downloaded directly.

Alternatively, you can install it with go: go install github.com/akquinet/pdnsgrep@latest

Configuration

Environment variables

export PDNSGREP_URL="https://pdns.example.domain"
export PDNSGREP_TOKEN="your-api-token"

Config file

A config file can be created under $HOME/.pdnsgrep.yaml or selected via --config.

---
url: "https://pdns.example.domain"
token: "your-api-token"
debug: false
verbose: false

Usage

Help

pdnsgrep --help

Record

❯ pdnsgrep "sub.example.domain"
Zone            Name              Type  Content         TTL
example.domain. sub.example.domain. A   [IPv4 Address]  300

IP

❯ pdnsgrep "10.187.102.42"
Zone             Name                 Type  Content         TTL
example2.domain. sub.example2.domain. A     [IPv4 Address]  300
example.domain.  sub.example.domain.  A     [IPv4 Address]  300

Multiple records

❯ pdnsgrep "fw" "fw*"
Zone            Name                      Type  Content          TTL
example.domain. fw.example.domain.        A     [IPv4 Address]   3600
example.domain. fw-ham-1.example.domain.  A     [IPv4 Address]   3600
example.domain. fw-ham-1.example.domain.  AAAA  [IPv6 Address]   3600

Only specific record types

❯ pdnsgrep "lab-asa" --type AAAA
Zone       Name                             Type   Content          TTL
example.domain. lab-asa-01.example.domain.  AAAA   [IPv6 Address]   3600
example.domain. lab-asa-02.example.domain.  AAAA   [IPv6 Address]   3600

Piping into less

❯ pdnsgrep "*firewall*" | less -S

Get only the names

❯ pdnsgrep "fw" --output raw --no-header | cut -d' ' -f 2 | sort -u
fw-01.example.domain
fw-02.example.domain.

CSV Export

❯ pdnsgrep "fw" --output csv
Zone;Name;Type;Content;TTL;Object Type
example.domain.;fw-1.example.domain.;AAAA;IPv6 Address;3600;record
example.domain.;fw-1.example.domain.;A;IPv4 Address;3600;record
....