This commit is contained in:
BuildTools committed 2026-11-22 14:51:07 +01:00
commit 93b8fe22d3
2 files changed
+84

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
# CF2PDNS
Converts a Cloudflare DNS zone export (BIND format) into CSV for Poweradmin's **Bulk add records** form.
## Usage
```
python3 cf2pa.py <export.txt> [more exports...]
```
The CSV is written to stdout and warnings go to stderr. Paste the output into
*Zone → Bulk add records* in Poweradmin.
Output format: `name,type,content,prio,ttl`
## What it does
- Skips `SOA` and `NS` records (these come from your Poweradmin zone template)
- Strips Cloudflare `cf_tags` comments and trailing dots
- Converts TTL `1` (Cloudflare "Auto") to `3600`
- Moves the MX/SRV priority into the `prio` column
- Escapes TXT quotes for CSV (`"..."` → `"""..."""`), keeping multi-string TXT (e.g. DKIM) intact
## Warnings (records not converted)
- **Apex CNAME**: Cloudflare flattens it, but standard DNS doesn't allow it. Add an `A`/`AAAA` record manually.
- **PTR records named `*.arpa.<zone>`**: these have no effect inside a forward zone. Set reverse DNS with your IP provider.
## Migration checklist
1. Disable DNSSEC at Cloudflare first and wait at least a day for the DS record's TTL to expire.
2. Create the zone in Poweradmin as **Master** using the NS template.
3. Bulk-import the CSV and verify that the secondary has the zone: `dig +short SOA <zone> @<ns2>`
4. Change the nameservers at the registrar.
5. Delete the Cloudflare zone a day later.
+49
View File
@@ -0,0 +1,49 @@
#!/usr/bin/env python3
# CF2PDNS: Cloudflare zone export -> Poweradmin bulk CSV (name,type,content,prio,ttl)
import sys, re
TTL = 3600 # replaces Cloudflare's TTL 1 ("Auto")
SKIP = {"SOA", "NS"} # provided by the Poweradmin zone template
def conv(path):
out, warn = [], []
apex = None
for line in open(path, encoding="utf-8"):
line = line.rstrip("\n")
if not line.strip() or line.lstrip().startswith(";"):
continue
line = re.sub(r"\s*;\s*cf_tags=.*$", "", line)
p = line.split(None, 4)
if len(p) < 5:
continue
name, ttl, _cls, typ, data = p
name = name.rstrip(".")
if typ == "SOA":
apex = name
if typ in SKIP:
continue
ttl = TTL if ttl == "1" else int(ttl)
prio = 0
if typ == "PTR" and ".arpa." in name + ".":
warn.append(f"PTR skipped: {name}")
continue
if typ in ("MX", "SRV"):
prio, data = data.split(None, 1)
elif typ == "TXT":
data = '"' + data.replace('"', '""') + '"'
if typ in ("CNAME", "MX", "SRV", "PTR"):
data = data.rstrip(".")
if typ == "CNAME" and name == apex:
warn.append(f"Apex CNAME {name} -> {data}: replace with A/AAAA")
continue
out.append(f"{name},{typ},{data},{prio},{ttl}")
return out, warn
if len(sys.argv) < 2:
sys.exit(f"usage: {sys.argv[0]} <export.txt> [...]")
for f in sys.argv[1:]:
out, warn = conv(f)
print("\n".join(out))
for w in warn:
print(f"# WARNING: {w}", file=sys.stderr)