Created
January 21, 2013 22:00
-
-
Save juparave/4589883 to your computer and use it in GitHub Desktop.
Building hosts files for bind9 from a list of domains in a txt file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 2013/01/21 | |
# Building hosts files for bind9 from a list of domains in a txt file | |
DNS=some.dnsserver.net | |
for d in `cat domains`; do | |
echo "\$ttl 38400" > $d.hosts | |
dig +nocmd @$DNS $d any +multiline +noall +answer >> $d.hosts | |
for cname in 'www' 'ftp' 'mail' 'webmail'; do | |
dig +nocmd @$DNS $cname.$d CNAME +multiline +noall +answer >> $d.hosts | |
done | |
# now include input in /etc/bind/named.conf.local | |
echo -e "zone \"$d\" {" >> /etc/bind/named.conf.local | |
echo -e "\ttype master;" >> /etc/bind/named.conf.local | |
echo -e "\tfile \"/var/lib/bind/$d.hosts\";" >> /etc/bind/named.conf.local | |
echo -e "\t};" >> /etc/bind/named.conf.local | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment