Managing dns

From ancoleman/ai-design-components · View interactive version

Managing dns is an AI agent skill from the GitHub repository ancoleman/ai-design-components. Manage DNS records, TTL strategies, and DNS-as-code automation for infrastructure. Use when configuring domain resolution, automating DNS from Kubernetes with external-dns, setting up DNS-based load balancing, or troubleshooting propagation issues across cloud providers (Route53, Cloud DNS, Azure DN

How to use this skill

Skill file

DNS Management

Configure and automate DNS records with proper TTL strategies, DNS-as-code patterns, and troubleshooting techniques.

Purpose

Guide DNS configuration for applications, infrastructure, and services with focus on:

When to Use This Skill

Apply DNS management patterns when:

Record Type Selection

Quick Reference

Address Resolution:

Email Configuration:

Service Discovery:

Delegation and Security:

Cloud-Specific:

Decision Tree

Need to point domain to:
├─ IPv4 Address? → A record
├─ IPv6 Address? → AAAA record
├─ Another Domain?
│  ├─ Zone apex (@) → ALIAS/ANAME or A record
│  └─ Subdomain → CNAME
├─ Mail Server? → MX record (with priority)
├─ Email Authentication? → TXT record (SPF/DKIM/DMARC)
├─ Service Discovery? → SRV record
├─ Domain Verification? → TXT record
├─ Certificate Control? → CAA record
└─ Subdomain Delegation? → NS record

For detailed record type examples and patterns, see references/record-types.md.

TTL Strategy

Standard TTL Values

By Change Frequency:

Key Principle: Lower TTL = faster propagation but higher DNS query load

Pre-Change Process

When planning DNS changes:

T-48h: Lower TTL to 300s
T-24h: Verify TTL propagated globally
T-0h:  Make DNS change
T+1h:  Verify new records propagating
T+6h:  Confirm global propagation
T+24h: Raise TTL back to normal (3600s)

Propagation Formula: Max Time = Old TTL + New TTL + Query Time

Example: Changing a record with 3600s TTL takes up to 2 hours to fully propagate.

TTL by Use Case

| Use Case | TTL | Rationale |

|----------|-----|-----------|

| Production (stable) | 3600s | Balance speed and load |

| Before planned change | 300s | Fast propagation |

| Development/staging | 300-600s | Frequent changes |

| DNS-based failover | 60-300s | Fast recovery |

| Mail servers | 3600s | Rarely change |

| NS records | 86400s | Very stable |

For detailed TTL scenarios and calculations, see references/ttl-strategies.md.

DNS-as-Code Tools

Tool Selection by Use Case

Kubernetes DNS Automation → external-dns

Multi-Provider DNS Management → OctoDNS or DNSControl

Infrastructure-as-Code → Terraform

Tool Comparison

| Tool | Language | Best For | Kubernetes | Multi-Provider |

|------|----------|----------|------------|----------------|

| external-dns | Go | K8s automation | ★★★★★ | ★★★★ |

| OctoDNS | Python/YAML | Version control | ★★★ | ★★★★★ |

| DNSControl | JavaScript | Complex logic | ★★ | ★★★★★ |

| Terraform | HCL | IaC integration | ★★★ | ★★★★ |

Quick Start: external-dns

# Kubernetes Service with DNS annotation
apiVersion: v1
kind: Service
metadata:
  name: app
  annotations:
    external-dns.alpha.kubernetes.io/hostname: app.example.com
    external-dns.alpha.kubernetes.io/ttl: "300"
spec:
  type: LoadBalancer
  ports:
    - port: 80

Deploy external-dns controller once, then all annotated Services/Ingresses automatically create DNS records.

For complete examples, see examples/external-dns/ and references/dns-as-code-comparison.md.

Cloud DNS Provider Selection

Provider Characteristics

AWS Route53

Google Cloud DNS

Azure DNS

Cloudflare

Selection Decision Tree

Choose based on:
├─ AWS-heavy? → Route53
├─ GCP-native? → Cloud DNS
├─ Azure-native? → Azure DNS
├─ Multi-cloud? → Cloudflare or OctoDNS/DNSControl
├─ Need fastest global DNS? → Cloudflare
├─ Need DDoS protection? → Cloudflare
└─ Budget-conscious? → Cloudflare (free tier) or Cloud DNS (lowest zone cost)

For detailed provider comparisons and examples, see references/cloud-providers.md.

DNS-Based Load Balancing

GeoDNS (Geographic Routing)

Return different IP addresses based on client location to:

Example Pattern:

Client Location → DNS Response
├─ North America → 192.0.2.1 (US data center)
├─ Europe → 192.0.2.10 (EU data center)
└─ Default → CloudFront edge (global CDN)

Weighted Routing

Distribute traffic by percentage for:

Example Pattern:

DNS Responses:
├─ 90% → 192.0.2.1 (stable version)
└─ 10% → 192.0.2.2 (canary version)

Health Check-Based Failover

Automatically route traffic away from unhealthy endpoints.

Pattern:

Primary: 192.0.2.1 (health checked every 30s)
├─ Healthy → Return primary IP
└─ Unhealthy → Return secondary IP (192.0.2.2)

Failover time: ~2-3 minutes
= Health check failures (90s) + TTL expiration (60s)

For complete load balancing examples, see examples/load-balancing/.

Troubleshooting

Essential Commands

Check DNS Resolution:

# Basic query
dig example.com

# Clean output (just IP)
dig example.com +short

# Query specific DNS server
dig @8.8.8.8 example.com
dig @1.1.1.1 example.com

# Trace resolution path
dig +trace example.com

Check TTL:

dig example.com | grep -A1 "ANSWER SECTION"
# Look for TTL value (number before IN A)

Check Propagation:

# Multiple resolvers
dig @8.8.8.8 example.com +short       # Google
dig @1.1.1.1 example.com +short       # Cloudflare
dig @208.67.222.222 example.com +short # OpenDNS

Flush Local DNS Cache:

# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Windows
ipconfig /flushdns

# Linux
sudo systemd-resolve --flush-caches

Common Problems

Slow Propagation:

CNAME at Zone Apex:

external-dns Not Creating Records:

For detailed troubleshooting, see references/troubleshooting.md.

Common Patterns

Pattern 1: Kubernetes DNS Automation

# Deploy external-dns (once per cluster)
helm install external-dns external-dns/external-dns \
  --set provider=aws \
  --set domainFilters[0]=example.com \
  --set policy=sync

# Then annotate Services
apiVersion: v1
kind: Service
metadata:
  annotations:
    external-dns.alpha.kubernetes.io/hostname: api.example.com
    external-dns.alpha.kubernetes.io/ttl: "300"
spec:
  type: LoadBalancer

Pattern 2: Multi-Provider Sync with OctoDNS

# octodns-config.yaml
providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./config
  route53:
    class: octodns_route53.Route53Provider
  cloudflare:
    class: octodns_cloudflare.CloudflareProvider

zones:
  example.com.:
    sources: [config]
    targets: [route53, cloudflare]

Pattern 3: DNS-Based Failover

# Route53 with health checks
resource "aws_route53_health_check" "primary" {
  fqdn              = "primary.example.com"
  port              = 443
  type              = "HTTPS"
  resource_path     = "/health"
  failure_threshold = 3
  request_interval  = 30
}

resource "aws_route53_record" "primary" {
  zone_id        = aws_route53_zone.main.zone_id
  name           = "api.example.com"
  type           = "A"
  ttl            = 60
  set_identifier = "primary"

  failover_routing_policy {
    type = "PRIMARY"
  }

  health_check_id = aws_route53_health_check.primary.id
  records         = ["192.0.2.1"]
}

resource "aws_route53_record" "secondary" {
  zone_id        = aws_route53_zone.main.zone_id
  name           = "api.example.com"
  type           = "A"
  ttl            = 60
  set_identifier = "secondary"

  failover_routing_policy {
    type = "SECONDARY"
  }

  records = ["192.0.2.2"]
}

Integration with Other Skills

infrastructure-as-code:

kubernetes-operations:

load-balancing-patterns:

security-hardening:

secret-management:

Additional Resources

Reference Documentation:

Examples:

Scripts:

Quick Reference

Record Types Cheat Sheet

| Record | Purpose | Example |

|--------|---------|---------|

| A | IPv4 address | example.com → 192.0.2.1 |

| AAAA | IPv6 address | example.com → 2001:db8::1 |

| CNAME | Alias to domain | www → example.com |

| MX | Mail server | 10 mail.example.com |

| TXT | Text/verification | "v=spf1 include:_spf.google.com ~all" |

| SRV | Service location | 10 60 5060 sip.example.com |

| NS | Nameserver delegation | ns1.provider.com |

| CAA | CA authorization | 0 issue "letsencrypt.org" |

TTL Cheat Sheet

| Scenario | TTL | Why |

|----------|-----|-----|

| Stable production | 3600s | Balance speed/load |

| Before change | 300s | Fast propagation |

| Failover | 60-300s | Fast recovery |

| NS records | 86400s | Very stable |

Provider Cheat Sheet

| Provider | Best For | Key Feature |

|----------|----------|-------------|

| Route53 | AWS | Advanced routing, health checks |

| Cloud DNS | GCP | DNSSEC, private zones |

| Azure DNS | Azure | Traffic Manager integration |

| Cloudflare | Multi-cloud | Fastest, DDoS protection, free tier |

Tool Cheat Sheet

| Tool | Use When |

|------|----------|

| external-dns | Kubernetes DNS automation |

| OctoDNS | Multi-provider, Python shop |

| DNSControl | Multi-provider, JavaScript preference |

| Terraform | Managing DNS with other infrastructure |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.