https://github.com/shuque/parse_zone
Parse master DNS zone format file and process it
https://github.com/shuque/parse_zone
Last synced: about 1 year ago
JSON representation
Parse master DNS zone format file and process it
- Host: GitHub
- URL: https://github.com/shuque/parse_zone
- Owner: shuque
- License: mit
- Created: 2025-06-20T01:21:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-22T02:13:59.000Z (about 1 year ago)
- Last Synced: 2025-06-22T03:24:03.604Z (about 1 year ago)
- Language: Python
- Size: 5.86 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DNS Zone File Parser
A Python script that parses and process a DNS master zone format file.
Note: this program was written by a series of (about 20) prompts to Cursor (an AI assisted code editor).
## Usage
### Basic Usage
```
$ ./parse_zone.py -h
usage: parse_zone.py [-h] [--printrecords] [--stats] [--no-dnssec]
[--rrtypes TYPES] [--includename NAME]
[--includedata DATA] [--excludename NAME]
[--excludedata DATA] [--wildcard] [--delegations]
[--ttl-min TTL] [--ttl-max TTL] [--class CLASS]
[zonefile]
Parse and display DNS zone file information
positional arguments:
zonefile Path to DNS zone file (read stdin if not provided)
options:
-h, --help show this help message and exit
--printrecords Print the (relevant) DNS records in the zone
--stats Print DNS record type statistics
--no-dnssec Exclude DNSSEC-related records
--rrtypes TYPES Comma-separated list of record types to include (e.g.,
A,AAAA,MX)
--includename NAME Include records with names containing string (case
insensitive)
--includedata DATA Include records with data containing string (case
insensitive)
--excludename NAME Exclude records with names containing string (case
insensitive)
--excludedata DATA Exclude records with data containing string (case
insensitive)
--wildcard Only process wildcard DNS records (names starting with
*.
--delegations Only process delegation records (NS records not for zone
origin)
--ttl-min TTL Minimum TTL value (inclusive) for filtering records
--ttl-max TTL Maximum TTL value (inclusive) for filtering records
--class CLASS Filter records by class (e.g., IN, CH, HS)
```
### Examples
```bash
# Parse a zone file silently (default behavior)
python3 parse_zone.py example.zone
# Print DNS records in formatted table
python3 parse_zone.py example.zone --printrecords
# Print record type statistics
python3 parse_zone.py example.zone --stats
# Print records with statistics
python3 parse_zone.py example.zone --printrecords --stats
# Only count records
python3 parse_zone.py example.zone --count-only
# Get help
python3 parse_zone.py --help
```
## Example Zone File
See `example.zone` for a sample DNS zone file that demonstrates various record types and formats.