DNS.Zone.FileParser (DNS v0.4.1)
View SourceDNS Zone file parser and generator for standard BIND format zone files.
Supports parsing and generation of DNS record types including:
- Standard records: SOA, NS, A, AAAA, CNAME, MX, TXT, SRV, PTR
- DNSSEC records: DNSKEY, DS, RRSIG, NSEC, NSEC3, NSEC3PARAM
- Security records: CAA, TLSA
- Modern records: HTTPS, SVCB
Handles:
- Comments (starting with ;)
- Line continuations
- Zone directives: $ORIGIN, $TTL, $INCLUDE, $GENERATE
- Class specifications (IN, CH, HS, NONE, ANY)
- TTL specifications and defaults
- Zone validation and error reporting
Summary
Functions
Generate a zone file string from zone data.
Parse a zone file from a string with enhanced error handling and validation.
Parse a zone file from a file path with enhanced error handling.
Parse a zone file from a string with detailed error reporting.
Validate zone data for common issues.
Types
Functions
Generate a zone file string from zone data.
Parse a zone file from a string with enhanced error handling and validation.
Examples
iex> zone_content = """
...> $ORIGIN example.com.
...> $TTL 3600
...> @ IN SOA ns1.example.com. admin.example.com. (
...> 2024010101 ; Serial
...> 3600 ; Refresh
...> 1800 ; Retry
...> 604800 ; Expire
...> 86400 ) ; Minimum TTL
...> @ IN NS ns1.example.com.
...> @ IN NS ns2.example.com.
...> ns1 IN A 192.0.2.1
...> ns2 IN A 192.0.2.2
...> www IN A 192.0.2.100
...> """
iex> {:ok, zone} = DNS.Zone.FileParser.parse(zone_content)
iex> length(zone.records)
5
iex> zone.origin
"example.com"
Parse a zone file from a file path with enhanced error handling.
Parse a zone file from a string with detailed error reporting.
Validate zone data for common issues.