Skip to content

lrqnet/PTR-Zone-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PTR Zone Generator

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.


πŸš€ Features

  • Supports multiple IP range formats:
    • 10.11.12.1-25 β†’ range from .1 to .25
    • 110.11.12.0/24 β†’ CIDR notation
    • 10.11.12.$ β†’ expands to .1 through .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

🧩 Requirements

  • Python 3.7+
  • No external dependencies required

πŸ’» Usage

python3 generate_ptrs.py \
  --domain example.com \
  --ns1 ns1.example.com \
  --ns2 ns2.example.com \
  --range 10.11.12.1-255

This will generate a file named:

db.12.11.10.in-addr.arpa.fqdn

🧾 Example Output

$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.

πŸ“‚ Output Files

  • db.<reversed-zone>.fqdn β†’ clean version ready to import into DNS servers such as Technitium or BIND.

🧠 Notes

  • 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.

"Buy Me A Coffee"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages