This script generates a minimal named.conf configuration file for BIND by scanning a directory of DNS zone files.
For each zone file, it extracts the zone name from the SOA record and creates a corresponding zone block.
./gen_named.sh <path_to_zone_files>- path_to_zone_files: Directory containing DNS zone files.
Example:
./gen_named.sh /etc/bind/zones- Validates input directory.
- Scans all files in the given directory.
- Extracts the zone name from the first SOA record found.
- Generates a
named.confwith minimal zone declarations:zone "example.com" { type master; file "/etc/bind/zones/example.com.zone"; }; - Warns if no SOA record is found in a zone file.
- A file named
named.confis created in the current working directory. - Example contents:
// Generated named.conf zone "example.com" { type master; file "/etc/bind/zones/example.com"; }; zone "example.org" { type master; file "/etc/bind/zones/example.org"; };
- Bash
- Standard UNIX tools:
grep,awk
- The script assumes each zone file contains a valid SOA record.
- If no SOA record is found, the file is skipped with a warning.
- Useful for quickly bootstrapping a
named.conffrom existing zone files.
This script is covered under the repository’s main MIT License.