virtual_server vip 53 { delay_loop 2 lb_algo rr lb_kind DR protocol UDP real_server real_server1 53 { weight 100 MISC_CHECK { misc_path "/etc/keepalived/check_named.sh real_server1" misc_timeout 5 } } real_server real_server2 53 { weight 100 MISC_CHECK { misc_path "/etc/keepalived/check_named.sh real_server2" misc_timeout 5 } } }
#!/bin/bash SERVER=$1 OK=`nslookup www.test.com $SERVER|grep ipxxxx` if [ "$OK" == "" ] ; then exit 1; else exit 0; fi
Name: Vipshop-Bind-Chroot Summary: This is for Vipshop dns server. Group: System Environment/Daemons Version: 1.0 Release: 0 License: Copyright 2011 Vipshop Inc. Source: Vipshop-Bind-Chroot-1.0.tar.gz URL: http://www.vipshop.com Packager: EricNi Vendor: Vipshop Inc. Provides: Vipshop Inc. BuildRequires: gcc-c++ %description This is DNS Service pakeage , and it only distributed in Vipshop Servers . %prep test -d /usr/local/named && rm -rf /usr/local/named [ `cat /etc/passwd|grep named|wc -l` -eq 0 ] && useradd named -M -s /sbin/nologin mkdir -p /usr/local/named /usr/local/named/var/slaves /usr/local/named/var/named /usr/local/named/var/etc /usr/local/named/var/log mkdir -p /var/named/chroot/etc/namedb /var/named/chroot/etc/log /var/named/chroot/etc/run /var/named/chroot/var/run /var/named/chroot/dev/ /var/named/chroot/etc/namedb/slaves /var/named/chroot/etc/namedb/acl %setup -n %{name}-%{version} %build export BIND_HOME=/usr/local/named export BIND_CHROOT_HOME=/var/named/chroot ./configure --prefix=${BIND_HOME} --enable-threads --sysconfdir=/etc --disable-openssl-version-check make make install cat > ${BIND_CHROOT_HOME}/etc/named.conf << "EOF" options { directory "/etc/namedb"; version "vipshop-cdn-dns"; pid-file "/etc/run/named.pid"; listen-on port 53 {any;}; allow-query {any;}; recursion yes; dump-file "/etc/namedb/cache_dump.db"; zone-statistics yes; statistics-file "/etc/namedb/named_stats.txt"; }; logging { channel warning {file "/etc/log/named.log" versions 3 size 2048k; severity warning; print-severity yes; print-category yes; print-time yes; }; channel query {file "/etc/log/query.log" versions 3 size 2048k; severity info; print-category yes; print-severity yes; print-time yes; }; category queries { query; }; category default { warning; }; }; zone "." IN { type hint; file "named.root"; }; zone "localhost" IN { type master; file "localhost.zone"; }; zone "0.0.127.in-addr.arpa" IN { type master; file "slaves/localhost.rev"; }; zone "vipshop.com" IN { type master; file "vipshop.zone"; notify yes; also-notify {180.186.22.62;}; allow-transfer { 180.186.22.62; }; }; key "rndc-key" { algorithm hmac-md5; secret "f8Na2kl/4NuCNPEZ0f2C1Q=="; }; controls { inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { "rndc-key"; }; }; EOF cat > ${BIND_CHROOT_HOME}/etc/rndc.conf << "EOF" key "rndc-key" { algorithm hmac-md5; secret "f8Na2kl/4NuCNPEZ0f2C1Q=="; }; options { default-key "rndc-key"; default-server 127.0.0.1; default-port 953; }; EOF cat > ${BIND_CHROOT_HOME}/etc/rndc.key << "EOF" key "rndc-key" { algorithm hmac-md5; secret "f8Na2kl/4NuCNPEZ0f2C1Q=="; }; EOF cat > /etc/rndc.conf << "EOF" key "rndc-key" { algorithm hmac-md5; secret "f8Na2kl/4NuCNPEZ0f2C1Q=="; }; options { default-key "rndc-key"; default-server 127.0.0.1; default-port 953; }; EOF cat > ${BIND_CHROOT_HOME}/etc/namedb/named.root << "EOF" ; This file holds the information on root name servers needed to ; initialize cache of Internet domain name servers ; (e.g. reference this file in the "cache . <file>" ; configuration file of BIND domain name servers). ; ; This file is made available by InterNIC ; under anonymous FTP as ; file /domain/named.cache ; on server FTP.INTERNIC.NET ; -OR- RS.INTERNIC.NET ; ; last update: Jan 3, 2013 ; related version of root zone: 2013010300 ; ; formerly NS.INTERNIC.NET ; . 3600000 IN NS A.ROOT-SERVERS.NET. A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 A.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:BA3E::2:30 ; ; FORMERLY NS1.ISI.EDU ; . 3600000 NS B.ROOT-SERVERS.NET. B.ROOT-SERVERS.NET. 3600000 A 192.228.79.201 ; ; FORMERLY C.PSI.NET ; . 3600000 NS C.ROOT-SERVERS.NET. C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12 ; ; FORMERLY TERP.UMD.EDU ; . 3600000 NS D.ROOT-SERVERS.NET. D.ROOT-SERVERS.NET. 3600000 A 199.7.91.13 D.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2D::D ; ; FORMERLY NS.NASA.GOV ; . 3600000 NS E.ROOT-SERVERS.NET. E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10 ; ; FORMERLY NS.ISC.ORG ; . 3600000 NS F.ROOT-SERVERS.NET. F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241 F.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:2F::F ; ; FORMERLY NS.NIC.DDN.MIL ; . 3600000 NS G.ROOT-SERVERS.NET. G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4 ; ; FORMERLY AOS.ARL.ARMY.MIL ; . 3600000 NS H.ROOT-SERVERS.NET. H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53 H.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:1::803F:235 ; ; FORMERLY NIC.NORDU.NET ; . 3600000 NS I.ROOT-SERVERS.NET. I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17 I.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FE::53 ; ; OPERATED BY VERISIGN, INC. ; . 3600000 NS J.ROOT-SERVERS.NET. J.ROOT-SERVERS.NET. 3600000 A 192.58.128.30 J.ROOT-SERVERS.NET. 3600000 AAAA 2001:503:C27::2:30 ; ; OPERATED BY RIPE NCC ; . 3600000 NS K.ROOT-SERVERS.NET. K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129 K.ROOT-SERVERS.NET. 3600000 AAAA 2001:7FD::1 ; ; OPERATED BY ICANN ; . 3600000 NS L.ROOT-SERVERS.NET. L.ROOT-SERVERS.NET. 3600000 A 199.7.83.42 L.ROOT-SERVERS.NET. 3600000 AAAA 2001:500:3::42 ; ; OPERATED BY WIDE ; . 3600000 NS M.ROOT-SERVERS.NET. M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33 M.ROOT-SERVERS.NET. 3600000 AAAA 2001:DC3::35 ; End of File EOF cat > ${BIND_CHROOT_HOME}/etc/namedb/localhost.zone << "EOF" $TTL 86400 $ORIGIN localhost. @ 1D IN SOA @ root ( 42 ; serial (d. adams) 3H ; refresh 15M ; retry 1W ; expiry 1D ) ; minimum 1D IN NS @ 1D IN A 127.0.0.1 EOF cat > ${BIND_CHROOT_HOME}/etc/namedb/localhost.rev << "EOF" $TTL 86400 @ IN SOA localhost. root.localhost. ( 1997022700 ; Serial 28800 ; Refresh 14400 ; Retry 3600000 ; Expire 86400 ) ; Minimum IN NS localhost. 1 IN PTR localhost. EOF cat > ${BIND_CHROOT_HOME}/etc/namedb/vipshop.zone << "EOF" $TTL 86400 @ IN SOA ns1.vipshop.com. root.vipshop.com. ( 2013051501 ; Serial 28800 ; Refresh 14400 ; Retry 3500000 ; Expire 86400 ) ; Minimum @ IN NS dns1 @ IN NS dns2 localhost IN A 127.0.0.1 img1 IN A xxxx img3 IN A xxxx img2 IN A xxxx img2 IN A xxxx dns1 IN A xxxx dns2 IN A xxxx EOF cat > /etc/init.d/named << "EOF" #!/bin/bash # # named This shell script takes care of starting and stopping # named (BIND DNS server). # # chkconfig: - 13 87 # description: named (BIND) is a Domain Name Server (DNS) \ # that is used to resolve host names to IP addresses. # probe: true # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network [ -r /etc/sysconfig/named ] && . /etc/sysconfig/named [ -f /usr/local/named/sbin/named ] || exit 0 # [ -f /chroot/named/etc/named.conf ] || exit 0 case "$1" in start) # Start daemons. echo -n "Starting named:" daemon /usr/local/named/sbin/named -c /etc/named.conf -u named -t /var/named/chroot echo touch /var/lock/subsys/named ;; stop) # Stop daemons. echo -n "Shutting down named:" #killproc named killall named rm -f /var/lock/subsys/named echo ;; status) #status named pid=`pidof -o %PPID -x named` if [ -z $pid ] then echo "named is stopped!!!" else echo "named is running: pid is $pid" fi exit $? ;; restart) $0 stop $0 start exit $? ;; reload) /usr/local/named/sbin/rndc reload exit $? ;; probe) /usr/local/named/sbin/rndc reload >/dev/null 2>&1 || echo start exit 0 ;; *) echo "Usage: named {start|stop|status|restart|reload}" exit 1 esac exit 0 EOF chmod 755 /etc/init.d/named mkdir -p /usr/local/named /usr/local/named/var/slaves /usr/local/named/var/named /usr/local/named/var/etc /usr/local/named/var/log mkdir -p /var/named/chroot/usr /var/named/chroot/etc/namedb /var/named/chroot/var/run /var/named/chroot/dev/ /var/named/chroot/etc/namedb/slaves /var/named/chroot/etc/run /var/named/chroot/etc/log /var/named/chroot/etc/namedb/acl chown named:named /var/named/chroot -R chown 700 /var/named/chroot mknod /var/named/chroot/dev/null c 1 3 mknod /var/named/chroot/dev/random c 1 8 cp /etc/localtime /var/named/chroot/etc/ sed -i 's/SYSLOGD_OPTIONS=\(.*\)/SYSLOGD_OPTIONS=\"-m 0 -a \/var\/named\/chroot\/dev\/log\"/g' /etc/sysconfig/syslog /etc/init.d/syslog restart %pre if [ ! `grep named /etc/passwd` ];then useradd -M named -s /sbin/nologin fi %post chkconfig --add named chkconfig named on chown named:named /var/named/chroot -R chown named:named /usr/local/named -R chown 700 /var/named/chroot %clean rm -rf /usr/local/named rm -rf /var/named %files /etc/init.d/named /usr/local/named/ /var/named/chroot/ %doc %changelog * Thu May 16 2013 Ericni <[email protected]>. - Create SPEC file.
本文出自 “菜光光的博客” 博客,转载请与作者联系!