Deleting Zones¶
Remove zones from BIND9.
Delete Zone¶
DELETE /api/v1/zones/{name}
Removes the zone from BIND9 and deletes the zone file.
Request¶
Response¶
{
"success": true,
"message": "Zone example.com deleted successfully",
"details": "zone 'example.com' was deleted"
}
Status Codes¶
200 OK- Zone deleted successfully401 Unauthorized- Missing/invalid token404 Not Found- Zone doesn't exist500 Internal Server Error- RNDC delete command failed
What Gets Deleted¶
When you delete a zone, bindcar automatically cleans up all related files:
- Zone removal from BIND9 - Executes
rndc delzoneto remove the zone from memory - Zone file deletion - Removes the
.zonefile from the filesystem (e.g.,example.com.zone) - Journal file cleanup - Automatically removes BIND9 journal files (
.zone.jnl) to prevent "journal out of sync" errors on zone recreation
This ensures complete cleanup and prevents any stale files from interfering with future zone operations.
Workflow¶
1. List Zones¶
Check which zones exist:
2. Verify Zone Info¶
Get zone details before deletion:
3. Delete Zone¶
4. Confirm Deletion¶
# Should return 404
curl http://localhost:8080/api/v1/zones/example.com \
-H "Authorization: Bearer $TOKEN"
Important Notes¶
- Deletion is immediate - No confirmation prompt
- Not reversible - Zone file is deleted
- Backup first - If you might need the zone later
- No cascade - Parent/child zones are independent
Safety Recommendations¶
Create Backup¶
# Before deletion, backup zone file
kubectl exec -it dns-pod -c bind9 -- \
cp /var/cache/bind/example.com.zone /backup/
# Or via Docker
docker cp bind9:/var/cache/bind/example.com.zone ./backup/
Export Zone Data¶
# Get zone configuration for re-creation
curl http://localhost:8080/api/v1/zones/example.com \
-H "Authorization: Bearer $TOKEN" > zone-backup.json
Troubleshooting¶
Zone Not Found¶
Solution: Verify zone name spelling and check zone list.
Permission Denied¶
Solution: Check BIND9 permissions and rndc configuration.
Next Steps¶
- Creating Zones - Create new zones
- Zone Status - Check zone information