Subdomain A Records — Routing Subdomains
Learn how to create A records for subdomains to route different services to different servers. Covers common patterns for blog, API, staging, and app subdomains.
AAddress Records
Zone File Entry
blog.example.com. IN A 203.0.113.60 api.example.com. IN A 203.0.113.70 staging.example.com. IN A 203.0.113.80
Detailed Explanation
Subdomain A Records
A subdomain A record maps a specific subdomain (like blog.example.com or api.example.com) to an IPv4 address. This is how you direct different services on your domain to different servers.
BIND Zone File Syntax
; Common subdomain layout
blog.example.com. 3600 IN A 203.0.113.60
api.example.com. 3600 IN A 203.0.113.70
staging.example.com. 3600 IN A 203.0.113.80
admin.example.com. 3600 IN A 203.0.113.90
cdn.example.com. 3600 IN A 203.0.113.100
; Using relative names (within the zone file for example.com)
blog 3600 IN A 203.0.113.60
api 3600 IN A 203.0.113.70
staging 300 IN A 203.0.113.80
When to Use Subdomain A Records vs. CNAME
Choose A records when:
- You control the target server and know its static IP address
- You need other record types (MX, TXT) at the same subdomain
- You want the fastest possible resolution (no extra CNAME lookup)
Choose CNAME when:
- The target is managed by a third party (CDN, SaaS platform) and the IP may change
- You want automatic updates when the target provider changes IPs
- There are no other record types needed at that subdomain
Common Subdomain Patterns
| Subdomain | Purpose | Example Target |
|---|---|---|
www |
Main website | Web server or CDN |
blog |
Blog or content site | CMS server |
api |
API endpoints | API gateway or server |
staging |
Pre-production testing | Staging server |
admin |
Admin panel | Internal server |
mail |
Mail server | SMTP server |
ftp |
File transfer | FTP server |
dev |
Development environment | Dev server |
Architectural Considerations
Each subdomain can point to an entirely different infrastructure:
www.example.com→ Vercel or Netlify (via CNAME)api.example.com→ AWS EC2 instance (via A record)blog.example.com→ WordPress on a VPS (via A record)mail.example.com→ Mail server IP (via A record, referenced by MX)
This flexibility allows teams to choose the best hosting solution for each service independently.
TTL Strategy for Subdomains
- Production subdomains (
www,api): Use longer TTLs like 3600 (1 hour) for stable endpoints - Staging/dev subdomains: Use shorter TTLs like 300 (5 minutes) since IPs change more frequently
- Before migrations: Lower TTL well in advance of any planned IP changes
Security Considerations
- Dangling DNS records: If you decommission a server but leave the A record in place, an attacker could claim that IP address and serve content on your subdomain. Always remove DNS records when retiring services.
- Subdomain takeover: Be especially careful with CNAME records pointing to external services — if your account with the service expires, an attacker may claim the endpoint.
- Access control: Consider using different IPs for public-facing and internal-only subdomains, combined with firewall rules.
Use Case
Create subdomain A records to route different parts of your infrastructure — such as API servers, blog platforms, staging environments, and admin panels — to their respective server IP addresses.