This Python script automatically generates a reverse DNS (PTR) zone file for IPv4 ranges.
Itβs designed for system administrators, ISPs, or network engineers who manage their own DNS servers.
- Supports multiple IP range formats:
10.11.12.1-25β range from.1to.25110.11.12.0/24β CIDR notation10.11.12.$β expands to.1through.254
- Customizable domain and nameservers
- Automatically generates the correct reverse zone name (
db.12.11.10.in-addr.arpa) - Clean FQDN output (no quoted names)
- Timestamp-based SOA serial
- Python 3.7+
- No external dependencies required
python3 generate_ptrs.py \
--domain example.com \
--ns1 ns1.example.com \
--ns2 ns2.example.com \
--range 10.11.12.1-255This will generate a file named:
db.12.11.10.in-addr.arpa.fqdn
$TTL 3600
@ IN SOA ns1.example.com. hostmaster.example.com. (
2025100801 ; Serial
3600 ; Refresh
1800 ; Retry
1209600 ; Expire
86400 ) ; Minimum TTL
;
IN NS ns1.example.com.
IN NS ns2.example.com.
1 IN PTR 10-11-12-1.example.com.
2 IN PTR 10-11-12-2.example.com.
3 IN PTR 10-11-12-3.example.com.
4 IN PTR 10-11-12-4.example.com.
5 IN PTR 10-11-12-5.example.com.
...
255 IN PTR 10-11-12-255.example.com.
db.<reversed-zone>.fqdnβ clean version ready to import into DNS servers such as Technitium or BIND.
- The script uses the system timezone for the SOA serial.
- If you regenerate the same file later, the serial automatically updates.
- Fully compatible with Technitium DNS Server, BIND, and PowerDNS.
