DNS STUFF

#!/bin/bash
 
#INSTALL BIND IF IT'S NOT ALREADY INSTALLED
rpm -q bind || yum -y install bind
 
#START CREATE ZONEFILE
#/var/named/homelab:
cat >/var/named/homelab<<EOF
\$TTL 7200
; homelab
; don't be a noob, increment the serial on every update
@       IN      SOA     ns01.homelab. postmaster.homelab. (
                                        2007011601 ; Serial
                                        28800      ; Refresh
                                        1800       ; Retry
                                        604800     ; Expire - 1 week
                                        86400 )    ; Minimum
                IN      NS      ns01
ns01            IN      A       192.168.0.18
localhost       IN      A       127.0.0.1
@               IN      A       192.168.0.18
www             IN      A       192.168.0.18
mail            IN      A       192.168.0.18
azeroth         IN      A       192.168.0.14
darnassus       IN      A       192.168.0.12
stormwind       IN      A       192.168.0.13
undercity       IN      A       192.168.0.15
silvermoon      IN      A       192.168.0.16
EOF
#END CREATE ZONEFILE
 
#EDIT/UPDATE BIND'S CONFIG FILE
cp -f /etc/named.conf /etc/named.conf.orig
sed -e 's/listen-on port 53.*/listen-on port 53 { 192.168.0.18; };/'    \
    -e 's/allow-query.*/allow-query { 192.168.1.0\/24; };/'             \
    -e 's/listen-on-v6.*/\/\/&/' /etc/named.conf.orig >/etc/named.conf
 
#ADD DNS ENTRY FOR HOME DNS DOMAIN IF NOT ALREADY PRESENT
grep home.lab /etc/named.conf || cat >>/etc/named.conf <<EOF
zone "home.lab" IN {
        type master;
        file "homelab";
        allow-update { none; };
        notify no;
};
EOF
 
#RE/START BIND AND CONFIG IT TO START AT BOOT
/etc/init.d/named restart
chkconfig named on
 
#EDIT DNS SETTINGS TO USE 192.168.0.18
grep 192.168.0.18 /etc/resolv.conf || echo
#OR JUST USE THIS ONE BELOW:
cat >/etc/resolv.conf<<EOF
search home.lab
nameserver 192.168.0.18
nameserver 8.8.8.8
EOF
 
 
 
#PROFIT
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code:

This site uses Akismet to reduce spam. Learn how your comment data is processed.