用shell腳本快速安裝、配置bind

#!/bin/bash
####################################################################
# Auto install bind
# Create Date :  2012-11-28
# Written by :shanks
####################################################################
yum install bind* >>/tmp/init_sn.log -y && rndc-confgen -r /dev/urandom -a || exit 1
  # ***config /etc/named.conf***
cat << shanks1  > /etc/named.conf
options {
  version "1.1.1";
  listen-on port 53 {any;};
  directory "/var/named/chroot/etc/";
  pid-file "/var/named/chroot/var/run/named/named.pid";
  allow-query { any; };
  Dump-file "/var/named/chroot/var/log/binddump.db";
  Statistics-file "/var/named/chroot/var/log/named_stats";
  zone-statistics yes;
  memstatistics-file "log/mem_stats";
  empty-zones-enable no;
#  allow-update {none;};
#  allow-recursion {any;};
#  serial-query-rate 100;
#  recursion no;
#  dnssec-enable yes;
};
key "rndc-key" {
        algorithm hmac-md5;
        secret "Fqw5YGeVfxUWeCMKBX/aBq==";
};
controls {
       inet 127.0.0.1 port 953
               allow { 127.0.0.1; } keys { "rndc-key"; };
 };
logging {
  channel warning {
    file "/var/named/chroot/var/log/dns_warning" versions 10 size 10m;
    severity warning;
    print-category yes;
    print-severity yes;
    print-time yes;
  };
  channel general_dns {
    file "/var/named/chroot/var/log/dns_log" versions 10 size 10m;
    severity info;
    print-category yes;
    print-severity yes;
    print-time yes;
  };
  category default {
    warning;
  };
  category queries {
    general_dns;
  };
};
include "/var/named/chroot/etc/view.conf";
shanks1
# ***config /etc/rndc.key***
cat << shanks2  > /etc/rndc.key
key "rndc-key" {
        algorithm hmac-md5;
        secret "Fqw5YGeVfxUWeCMKBX/aBq==";
};
shanks2
# ***config /etc/rndc.conf***
cat << shanks3  > /etc/rndc.conf
# Start of rndc.conf
key "rndc-key" {
        algorithm hmac-md5;
        secret "Eqw4hClGExUWeDkKBX/pBg==";
};
options {
        default-key "rndc-key";
        default-server 127.0.0.1;
        default-port 953;
};
shanks3
# ***config /var/named/chroot/etc/view.conf***
cat << shanks4  > /var/named/chroot/etc/view.conf
view "View" {
             allow-transfer {
                #dns-ip-list;
        };     
             notify  yes;
             also-notify {
                #dns-ip-list;
        };
         
#  ixfr-from-differences yes;
zone "com" {
        type    master;
        file    "com.zone";
        allow-transfer {
                10.255.253.211;
        };
        notify  yes;
        also-notify {
                10.255.253.211;
        };
  };
};
shanks4
# ***config  /var/named/chroot/etc/com.zone***
cat << shanks5  >  /var/named/chroot/etc/com.zone
\$ORIGIN .
\$TTL 3600       ; 1 hour
com                  IN SOA  dns246. hostmaster. (
                                2000       ; serial
                                900        ; refresh (15 minutes)
                                600        ; retry (10 minutes)
                                86400      ; expire (1 day)
                                3600       ; minimum (1 hour)
                                )
                        NS      dns246.
\$ORIGIN com.
pp711              A       1.2.3.4
shanks5
chown -R named.named /var/named
/etc/init.d/named start
chkconfig named on
#check install status.
check_cmd=`host  -s -W 0.5 pp711.com 127.0.0.1|grep "1.2.3.4"`
if [ -z "${check_cmd}" ]
then
  echo "<ERROR!> hey,man.install bind --- ERROR!"
else
  echo "<OK> hey,man.install bind --- ok."
fi
if [ -f /tmp/Install_bind.sh ]
then
  rm -rf /tmp/Install_bind.sh
fi


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章