Skip to content

Instantly share code, notes, and snippets.

@mxmader
Created August 4, 2015 17:59
Show Gist options
  • Save mxmader/dbd24a7c27465fc3b845 to your computer and use it in GitHub Desktop.
Save mxmader/dbd24a7c27465fc3b845 to your computer and use it in GitHub Desktop.
#!/bin/bash
domain=$1
if [ ! "$domain" ]; then
domain=acedemo.us
fi
echo "installing bind"
yum install -y bind bind-utils
echo "enabling service"
chkconfig named on
echo "configuring named service"
cat <<EOF > /etc/named.conf
//
// named.conf
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
listen-on port 53 { 127.0.0.1; 11.0.0.3; };
#listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { localhost; 192.168.1.0/24; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
managed-keys-directory "/var/named/dynamic";
forwarders { 8.8.8.8; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
zone "." IN {
type hint;
file "named.ca";
};
zone "${domain}" IN { # FORWARD Zone file and configuration
type master;
file "fwd.${domain}";
allow-update { none; };
};
zone "1.168.192.in-addr.arpa" IN { # REVERSE Zone file and configuration
type master;
file "rev.${domain}";
allow-update { none; };
};
include "/etc/named.rfc1912.zones";
include "/etc/named.root.key";
EOF
echo "configuring $domain forward lookup"
cat <<EOF > /var/named/fwd.${domain}
\$TTL 86400
@ IN SOA foo1.${domain}. root.${domain}. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS ns1.${domain}.
ns1 IN A 192.168.1.11
auth IN A 192.168.1.11
compute1 IN A 192.168.1.5
EOF
echo "configuring $domain reverse lookup"
cat <<EOF > /var/named/rev.${domain}
\$TTL 86400
@ IN SOA foo1.${domain}. root.${domain}. (
2011071001 ;Serial
3600 ;Refresh
1800 ;Retry
604800 ;Expire
86400 ;Minimum TTL
)
@ IN NS ns1.${domain}.
ns1 IN A 192.168.1.11
auth IN A 192.168.1.11
compute1 IN A 192.168.1.5
153 IN PTR auth.${domain}
7 IN PTR compute1.${domain}
EOF
service named restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment