NetBox IPAM and PowerDNS integration for automated DNS record management.
Automate DNS record management by integrating NetBox IPAM with PowerDNS. Use this when creating infrastructure that needs automatic DNS records, or querying NetBox for IPAM data and DNS naming validation.
/plugin marketplace add basher83/lunar-claude/plugin install git-workflow@lunar-claudeThis skill inherits all available tools. When active, it can use any tool Claude has access to.
anti-patterns/common-mistakes.mdexamples/01-vm-with-dns/README.mdexamples/01-vm-with-dns/main.tfexamples/01-vm-with-dns/variables.tfreference/netbox-api-guide.mdreference/netbox-best-practices.mdreference/netbox-data-models.mdreference/sync-plugin-reference.mdreference/terraform-provider-guide.mdtools/netbox_api_client.pytools/netbox_ipam_query.pytools/netbox_vm_create.pytools/validate_dns_naming.pyworkflows/ansible-dynamic-inventory.mdworkflows/dns-automation.mdworkflows/naming-conventions.mdExpert guidance for implementing NetBox as your source of truth for infrastructure documentation and automating DNS record management with PowerDNS.
Query NetBox API:
# List all sites
./tools/netbox_api_client.py sites list
# Get device details
./tools/netbox_api_client.py devices get --name foxtrot
# List VMs in cluster
./tools/netbox_api_client.py vms list --cluster matrix
# Query IPs
./tools/netbox_api_client.py ips query --dns-name docker-01
Create VM in NetBox:
# Create VM with auto-assigned IP
./tools/netbox_vm_create.py --name docker-02 --cluster matrix --vcpus 4 --memory 8192
# Create VM with specific IP
./tools/netbox_vm_create.py --name k8s-01-master --cluster matrix --ip 192.168.3.50/24
IPAM Queries:
# Get available IPs
./tools/netbox_ipam_query.py available --prefix 192.168.3.0/24
# Check prefix utilization
./tools/netbox_ipam_query.py utilization --site matrix
# View IP assignments
./tools/netbox_ipam_query.py assignments --prefix 192.168.3.0/24
Validate DNS Naming:
./tools/validate_dns_naming.py --name "docker-01-nexus.spaceships.work"
Deploy from NetBox Inventory:
cd ansible && uv run ansible-playbook -i tools/netbox-dynamic-inventory.yml deploy-from-netbox.yml
Activate this skill when:
service-NN-purpose.domain patternQuery infrastructure data:
#!/usr/bin/env -S uv run --script --quiet
# /// script
# requires-python = ">=3.11"
# dependencies = ["pynetbox>=7.0.0", "infisical-python>=2.3.3"]
# ///
import pynetbox
from infisical import InfisicalClient
# Get token from Infisical
client = InfisicalClient()
token = client.get_secret(
secret_name="NETBOX_API_TOKEN",
project_id="7b832220-24c0-45bc-a5f1-ce9794a31259",
environment="prod",
path="/matrix"
).secret_value
# Connect to NetBox
nb = pynetbox.api('https://netbox.spaceships.work', token=token)
# Query devices in Matrix cluster
site = nb.dcim.sites.get(slug='matrix')
devices = nb.dcim.devices.filter(site='matrix')
for device in devices:
print(f"{device.name}: {device.primary_ip4.address if device.primary_ip4 else 'No IP'}")
See reference/netbox-api-guide.md for complete API reference.
This infrastructure uses the pattern: <service>-<number>-<purpose>.<domain>
Examples:
docker-01-nexus.spaceships.work - Docker host #1 running Nexusproxmox-foxtrot-mgmt.spaceships.work - Proxmox node Foxtrot management interfacek8s-01-master.spaceships.work - Kubernetes cluster master node #1Implementation:
# tools/validate_dns_naming.py validates this pattern
pattern = r'^[a-z0-9-]+-\d{2}-[a-z0-9-]+\.[a-z0-9.-]+$'
See workflows/naming-conventions.md for complete rules.
# In NetBox virtualenv
pip install netbox-powerdns-sync
# /opt/netbox/netbox/netbox/configuration.py
PLUGINS = ['netbox_powerdns_sync']
PLUGINS_CONFIG = {
"netbox_powerdns_sync": {
"powerdns_managed_record_comment": "netbox-managed",
"post_save_enabled": True, # Real-time sync
},
}
Configure zones with:
spaceships.work)production-dns)See reference/sync-plugin-reference.md for details.
Provider Setup:
terraform {
required_providers {
netbox = {
source = "e-breuninger/netbox"
version = "~> 5.0.0"
}
}
}
provider "netbox" {
server_url = "https://netbox.spaceships.work"
api_token = var.netbox_api_token
}
Create IP with Auto-DNS:
resource "netbox_ip_address" "docker_host" {
ip_address = "192.168.1.100/24"
dns_name = "docker-01-nexus.spaceships.work"
description = "Docker host for Nexus registry"
tags = [
"terraform",
"production-dns" # Triggers auto DNS sync
]
}
DNS records created automatically by plugin!
See reference/terraform-provider-guide.md and examples/netbox-terraform-provider.tf.
Use NetBox as Inventory Source:
# tools/netbox-dynamic-inventory.yml
plugin: netbox.netbox.nb_inventory
api_endpoint: https://netbox.spaceships.work
token: !vault |
$ANSIBLE_VAULT;...
group_by:
- device_roles
- tags
Deploy Using NetBox Data:
ansible-playbook -i tools/netbox-dynamic-inventory.yml deploy-from-netbox.yml
See workflows/ansible-dynamic-inventory.md.
1. Create/Update resource in NetBox
└→ IP Address with dns_name and tags
2. NetBox PowerDNS Sync Plugin activates
└→ Matches IP to zone based on tags
└→ Generates DNS records
3. PowerDNS API called
└→ A record: docker-01-nexus.spaceships.work → 192.168.1.100
└→ PTR record: 100.1.168.192.in-addr.arpa → docker-01-nexus.spaceships.work
4. DNS propagates automatically
└→ No manual DNS configuration needed
Terraform/Ansible
↓
Creates VM in Proxmox
↓
Registers in NetBox (via API)
├→ Device object
├→ IP Address with dns_name
└→ Tags (production-dns)
↓
NetBox PowerDNS Sync
↓
DNS Records in PowerDNS
↓
Ansible Dynamic Inventory
↓
Automated configuration management
netbox_api_client.py - Comprehensive NetBox API client
# List sites, devices, VMs, IPs
./tools/netbox_api_client.py sites list
./tools/netbox_api_client.py devices get --name foxtrot
./tools/netbox_api_client.py vms list --cluster matrix
./tools/netbox_api_client.py ips query --dns-name docker-01
./tools/netbox_api_client.py prefixes available --prefix 192.168.3.0/24
netbox_vm_create.py - Create VMs in NetBox with IP assignment
# Create VM with auto IP
./tools/netbox_vm_create.py --name docker-02 --cluster matrix --vcpus 4 --memory 8192
# Create VM with specific IP
./tools/netbox_vm_create.py --name k8s-01-master --cluster matrix --ip 192.168.3.50/24
netbox_ipam_query.py - Advanced IPAM queries
# Available IPs
./tools/netbox_ipam_query.py available --prefix 192.168.3.0/24
# Prefix utilization
./tools/netbox_ipam_query.py utilization --site matrix
# IP assignments
./tools/netbox_ipam_query.py assignments --prefix 192.168.3.0/24
# IPAM summary
./tools/netbox_ipam_query.py summary --site matrix
validate_dns_naming.py - Validate DNS naming conventions
./tools/validate_dns_naming.py --name "docker-01-nexus.spaceships.work"
netbox-data-sources.tf - Examples using NetBox provider
deploy-from-netbox.yml - Deploy using NetBox inventory
See examples/ directory.
# Verify IP has correct tags
./tools/netbox_query.py --ip 192.168.1.100 | jq '.tags'
./tools/powerdns_sync_check.py --zone spaceships.work --verbose
Validate names before creating:
./tools/validate_dns_naming.py --name "my-proposed-name.domain"
Common mistakes:
Version mismatch:
Warning: NetBox version 4.3.0 not supported by provider 3.9.0
Solution: Update provider version:
version = "~> 5.0.0" # Match NetBox 4.3.x
Check API connectivity:
curl -H "Authorization: Token YOUR_TOKEN" \
https://netbox.spaceships.work/api/dcim/devices/
Verify inventory plugin:
ansible-inventory -i tools/netbox-dynamic-inventory.yml --list
See troubleshooting/ for more details.
service-NN-purpose.domain patternproduction-dns, lab-dns)post_save_enabled for immediate DNS updatesdns_record_audit.py to verify syncdocker-NN-<app> - Docker hostsk8s-NN-<role> - Kubernetes nodesproxmox-<node>-<iface> - Proxmox infrastructurestorage-NN-<purpose> - Storage systemsdb-NN-<dbtype> - Database serversdocker-01-nexus.spaceships.work # Nexus container registry
k8s-01-master.spaceships.work # K8s control plane
k8s-02-worker.spaceships.work # K8s worker node
proxmox-foxtrot-mgmt.spaceships.work # Proxmox mgmt interface
proxmox-foxtrot-ceph.spaceships.work # Proxmox CEPH interface
storage-01-nas.spaceships.work # NAS storage
db-01-postgres.spaceships.work # PostgreSQL database
For deeper knowledge:
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.