免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 12975 | 回复: 14
打印 上一主题 下一主题

[DNS] [原創] 簡單建立 dns 的 shell script [复制链接]

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-12-06 01:50 |只看该作者 |倒序浏览
常碰到一些朋友抱怨說 linux 的  dns 很難設。
但經我個人觀察,90% 都是打錯字或格式疏忽而已~~~~  ^_^

這裡我寫了隻 shell script ,可以幫助建立簡單的正解及反解檔,
然後將剩下的"簡單"的部份,則自己來修改了...

download:
http://www.study-area.org/linux/src/sample_dns.sh.tgz

最後版原始碼:
  1. #!/bin/bash
  2. set -u

  3. # purpose: make a sample dns for RedHat like system
  4. # author: netman<netman@study-area.org>
  5. # date: 2003-12-12
  6. # version: v0.6

  7. #-- CAVEATE --#
  8. # 1) script has been tested only on RedHat 8.x/9.0 platform.
  9. # 2) needs root privilege to run.
  10. # 3) only one forward zone and one reverse zone will be created.
  11. #       if no specified zone names are given, script will assume to
  12. #       use the current DNS domain(using text.cxm instead if not found) for
  13. #       forward zone's name, and the Class-C ipv4 subnet of current IP for
  14. #       reverse zone's name.
  15. # 4) the script can NOT determine whether you have the proper delegation,
  16. #       you should manually delete ANY non-authorized zone settings.
  17. # 5) only followint Resource Record will be create by this script:
  18. #       * SOA (both forward & reverse)
  19. #       * NS (both forward & reverse)
  20. #       * MX (forward only)
  21. #       * A (forward only)
  22. #       * CNAME (www & ftp, forward only)
  23. #       * PTR (reverse only)
  24. # 6) a backup for named.conf and db directory will be made to /root/backup.
  25. #       backup will be performed once during the first running only,
  26. #       unless -b options is given.
  27. # 7) absolutely NO WARRANTY while running this script.

  28. #-- CHANGE LOG --#
  29. # 1) 2003-12-05 v0.1 by netman
  30. #       * first version.
  31. # 2) 2003-12-06 v0.2 by netman
  32. #       * improve options selection, and add:
  33. #               -f, -r, -n
  34. # 3) 2003-12-06 v0.3 by netman
  35. #       * improve name server hostname determination
  36. # 4) 2003-12-07 v0.4 by netman
  37. #       * re-organize options dtermination, and add:
  38. #               -c, -d, -e
  39. # 5) 2003-12-10 v0.5 by netman
  40. #       * bug-fixed to solve:
  41. #               - ip alias address: have primary only
  42. #               - no dns domain: set to test.cxm
  43. #               - no hostname: set to ns1
  44. # 6) 2003-12-12 v0.6 by netman
  45. #       * bug-fixed to solve:
  46. #               - backup dir detection


  47. #-- setting default values --#
  48. wtty=$(ps | grep $$ | tail -n 1 | awk '{print $2}')
  49. interact=
  50. test=
  51. to_file=
  52. backup=
  53. update=

  54. #-- print message --#
  55. function print_usage {
  56.         echo "-------------------------------------------------------------"
  57.         echo "Script Name:"
  58.         echo -e "\t${0##*/}"
  59.         echo "Usage:"
  60.         echo -e "\t${0##*/} [-h]"
  61.         echo -en "\t${0##*/} [-g|-t] [-u] [-b] [-i|"
  62.         echo -n "[-f fwd_zone] [-r rev_zone] [-n name_server]]"
  63.         echo " [-c conf_file] [-d db_dir] [-e ether_if]"
  64.         echo "Options:"
  65.         echo -e "\t-h\tprint this help"
  66.         echo -e "\t-g\trun the script"
  67.         echo -e "\t-i\tspecify own names interactively"
  68.         echo -e "\t-f\tname of forward zone"
  69.         echo -e "\t-r\tname of reverse zone"
  70.         echo -e "\t-n\tname of name-server"
  71.         echo -e "\t-t\ttest only"
  72.         echo -e "\t-u\tforce update db(s)"
  73.         echo -e "\t-b\tforce backup"
  74.         echo -e "\t-c\tpath of named.conf"
  75.         echo -e "\t-d\tpath of named database directory"
  76.         echo -e "\t-e\tethernet interface"
  77.         echo "Example:"
  78.         echo -e "\t# $0 -tu"
  79.         echo -e "\t# $0 -g -f test.cxm -r 3.2.1.in-addr.arpa -n ns.test.cxm"
  80.         echo "-------------------------------------------------------------"
  81.         exit 0
  82. }

  83. #-- getting options --#
  84. while getopts ":hgif:r:n:tubc:d:e:" opt; do
  85.         case "$opt" in
  86.                 h) print_usage ;;
  87.                 g) : ;;
  88.                 f) fwd_zone=$OPTARG ;;
  89.                 r) rev_zone=$OPTARG ;;
  90.                 n) ns_host=$OPTARG ;;
  91.                 i) interact=true ;;
  92.                 t) test=true; to_file=/dev/$wtty ;;
  93.                 u) update=true ;;
  94.                 b) backup=true ;;
  95.                 c) named_conf=$OPTARG ;;
  96.                 d) db_dir=$OPTARG ;;
  97.                 e) host_if=$OPTARG ;;
  98.                 \?) print_usage ;;
  99.         esac
  100. done

  101. #-- setting named info --#
  102. named_conf=${named_conf:-/etc/named.conf}
  103. db_dir=${db_dir:-/var/named}
  104. bak_dir=${bak_dir:-/root/backup}

  105. #-- setting zone info --#
  106. fwd_zone=$(hostname -d)
  107. fwd_zone=${fwd_zone:-test.cxm}
  108. host_if=${host_if:-eth0}
  109. host_ip=$(/sbin/ifconfig | grep -A1 $host_if[^:] | awk '/inet/{print $2}' | sed 's/^.*://')
  110. host_ip=${host_ip:-192.168.1.1}
  111. rev_fix=in-addr.arpa
  112. rev_zone=${rev_zone:-$(echo ${host_ip%.*} | awk -F. '{print $3"."$2"."$1}').$rev_fix}
  113. host_name=$(hostname -s)
  114. host_name=${host_name:-ns1}
  115. ns_host=${ns_host:-$host_name.$fwd_zone}
  116. ns_ptr=${host_ip##*.}
  117. serial_nu=$(date +%Y%m%d)01
  118. opt_ttl=86400

  119. #-- setting functions --#
  120. function print_choice {
  121.         echo
  122.         echo "Please select one:"
  123.         echo "h): to print HELP."
  124.         echo "t): to TEST the script only."
  125.         echo "q): to QUIT."
  126.         echo -n 'Your choice? '
  127.         read action
  128.         case $action in
  129.                 h|H) print_usage ;;
  130.                 t|T) exec $0 -t ;;
  131.                 q|Q) echo; exit 0 ;;
  132.                 *) print_choice ;;
  133.         esac
  134. }

  135. [ $# -eq 0 ] && {
  136.         echo
  137.         echo "${0##*/}: Error: missing argument."
  138.         print_choice
  139. }

  140. function get_zone {
  141.         echo
  142.         echo "Which name you would like to assign to the $1 zone? "
  143.         echo "(press Enter for '$2', or press 'n' for none): "
  144.         read z_name
  145.         echo $z_name | grep -q ' ' && {
  146.                 echo "Error: no space allowed in zone name."
  147.                 echo "  Press ctrl-c to abort or type again:"
  148.                 get_zone $1 $2
  149.         }
  150.         if [ -z "$z_name" ]; then
  151.                 z_name=$2
  152.         elif [ "$z_name" = "n" ]; then
  153.                 z_name=
  154.         fi
  155. }

  156. function run_intact {
  157.         get_zone forward $fwd_zone
  158.         fwd_zone=${z_name%.}
  159.         get_zone reverse $rev_zone
  160.         rev_zone=${z_name%.}
  161.         echo
  162.         echo "Give the FQDN of your name-server"
  163.         echo "(or press Enter for system defaults '$ns_host'): "
  164.         read _ns_host
  165.         ns_host=${_ns_host:-$ns_host}
  166. }

  167. #-- prepare target dir --#
  168. function pre_dir {
  169.   for dir in $@; do
  170.         if [ -e $dir -a ! -d $dir ]; then
  171.                 echo "${0##*/}: Error: $dir existed but is not a directory."
  172.                 exit 1
  173.         else
  174.                 mkdir -p $dir || {
  175.                         echo "${0##*/}: Error: Can't create dir: $dir !"
  176.                         exit 1
  177.                 }
  178.         fi
  179.   done
  180. }

  181. [ "$test" = true ] || pre_dir ${bak_dir} ${named_conf%/*} $db_dir

  182. #-- test permission --#
  183. for target in $named_conf $db_dir $bak_dir; do
  184.         [ -e $target ] || continue
  185.         [ -w $target ] || {
  186.                 echo "${0##*/}: Error: you have no write perssion to $target"
  187.                 exit 2
  188.         }
  189. done

  190. #-- make backup --#
  191. function run_bak {
  192.         [ -e $source -a -d $bak_dir ] && {
  193.                 cp -a $source $bak_dir || {
  194.                         echo "${0##*/}: Error:can't make backup for $source "
  195.                         exit 3
  196.                 }
  197.         }
  198. }
  199. function do_backup {
  200.   for source in $named_conf $db_dir; do
  201.         [ "$backup" = true ] && op=';' || op='||'
  202.         eval test -e $bak_dir/${source##*/} $op run_bak
  203.   done
  204. }

  205. #-- create default settings if missing --#
  206. function create_raw {

  207.   test -e $named_conf || {
  208.         echo "${0##*/}: WARNING: $named_conf seems missing!"
  209.         echo -n "Do you want me to create it for you? (y/N): "
  210.         read YN
  211.         echo $YN | grep -Eq 'Y|y' || return 0

  212.   cat > $named_conf <<END
  213. // generated by ${0##*/} on $(date)

  214. options {
  215.         directory "$db_dir";
  216. };
  217. zone "." IN {
  218.         type hint;
  219.         file "named.ca";
  220. };

  221. zone "localhost" IN {
  222.         type master;
  223.         file "localhost.zone";
  224.         allow-update { none; };
  225. };

  226. zone "0.0.127.in-addr.arpa" IN {
  227.         type master;
  228.         file "named.local";
  229.         allow-update { none; };
  230. };

  231. END


  232. test -e $db_dir/named.ca || {
  233.   cat > $db_dir/named.ca <<END
  234. ;       This file holds the information on root name servers needed to
  235. ;       initialize cache of Internet domain name servers
  236. ;       (e.g. reference this file in the "cache  .  <file>"
  237. ;       configuration file of BIND domain name servers).
  238. ;
  239. ;       This file is made available by InterNIC
  240. ;       under anonymous FTP as
  241. ;           file                /domain/named.cache
  242. ;           on server           FTP.INTERNIC.NET
  243. ;
  244. ;       last update:    Nov 5, 2002
  245. ;       related version of root zone:   2002110501
  246. ;
  247. ;
  248. .                        3600000  IN  NS    A.ROOT-SERVERS.NET.
  249. A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
  250. .                        3600000      NS    B.ROOT-SERVERS.NET.
  251. B.ROOT-SERVERS.NET.      3600000      A     128.9.0.107
  252. .                        3600000      NS    C.ROOT-SERVERS.NET.
  253. C.ROOT-SERVERS.NET.      3600000      A     192.33.4.12
  254. .                        3600000      NS    D.ROOT-SERVERS.NET.
  255. D.ROOT-SERVERS.NET.      3600000      A     128.8.10.90
  256. .                        3600000      NS    E.ROOT-SERVERS.NET.
  257. E.ROOT-SERVERS.NET.      3600000      A     192.203.230.10
  258. .                        3600000      NS    F.ROOT-SERVERS.NET.
  259. F.ROOT-SERVERS.NET.      3600000      A     192.5.5.241
  260. .                        3600000      NS    G.ROOT-SERVERS.NET.
  261. G.ROOT-SERVERS.NET.      3600000      A     192.112.36.4
  262. .                        3600000      NS    H.ROOT-SERVERS.NET.
  263. H.ROOT-SERVERS.NET.      3600000      A     128.63.2.53
  264. .                        3600000      NS    I.ROOT-SERVERS.NET.
  265. I.ROOT-SERVERS.NET.      3600000      A     192.36.148.17
  266. .                        3600000      NS    J.ROOT-SERVERS.NET.
  267. J.ROOT-SERVERS.NET.      3600000      A     192.58.128.30
  268. .                        3600000      NS    K.ROOT-SERVERS.NET.
  269. K.ROOT-SERVERS.NET.      3600000      A     193.0.14.129
  270. .                        3600000      NS    L.ROOT-SERVERS.NET.
  271. L.ROOT-SERVERS.NET.      3600000      A     198.32.64.12
  272. .                        3600000      NS    M.ROOT-SERVERS.NET.
  273. M.ROOT-SERVERS.NET.      3600000      A     202.12.27.33
  274. ; End of File
  275. END
  276. }

  277. test -e $db_dir/localhost.zone || {
  278.   cat > $db_dir/localhost.zone <<END
  279. \$TTL   86400
  280. \$ORIGIN localhost.
  281. @                       1D IN SOA       @ root (
  282.                                         42              ; serial (d. adams)
  283.                                         3H              ; refresh
  284.                                         15M             ; retry
  285.                                         1W              ; expiry
  286.                                         1D )            ; minimum

  287.                         1D IN NS        @
  288.                         1D IN A         127.0.0.1

  289. END
  290. }
  291. test -e $db_dir/named.local || {
  292.   cat > $db_dir/named.local <<END
  293. \$TTL   86400
  294. @       IN      SOA     localhost. root.localhost.  (
  295.                                       1997022700 ; Serial
  296.                                       28800      ; Refresh
  297.                                       14400      ; Retry
  298.                                       3600000    ; Expire
  299.                                       86400 )    ; Minimum
  300.               IN      NS      localhost.

  301. 1       IN      PTR     localhost.

  302. END
  303. }

  304. } # end of first test
  305. } # end of function

  306. #-- check named.conf --#
  307. function check_conf {
  308.   war_msg="${0##*/}: WARNING: \n\t$named_conf seems up-to-date. Nothing will be done. "
  309.   adv_msg="If you really want to continue, you can:"
  310.   for zone in $@; do
  311.         [ -e $named_conf ] && grep -Eq "$zone" $named_conf && {
  312.                 echo -e "$war_msg"
  313.                 echo "$adv_msg"
  314.                 echo "1) delete '$fwd_zone' & '$rev_zone' sections from $named_conf."
  315.                 echo "   OR:"
  316.                 echo "2) run '${0##*/} -u' to override db files in $db_dir."
  317.                 echo -e "   Note: this option will not modify $named_conf."
  318.                 exit 4
  319.         }
  320.   done
  321. }

  322. #-- modify named.conf --#
  323. function mod_conf {
  324.   for zone in $@; do
  325.         [ "$to_file" ] && {
  326.                 echo
  327.                 echo "Content will be written to $named_conf :"
  328.                 echo "----start-------------------------------------"
  329.         }
  330.         cat >> ${to_file:-$named_conf} <<END
  331. zone "$zone" IN {
  332.         type master;
  333.         file "$zone";
  334. };

  335. END
  336.         [ "$to_file" ] && {
  337.                 echo "----end---------------------------------------"
  338.         }
  339.   done
  340. }

  341. #-- modify rr db --#
  342. function mod_rr {
  343.   ns_host=${ns_host%.}
  344.   echo $ns_host | grep -q '\.' || ns_host=$ns_host.$fwd_zone
  345.   [ "$fwd_zone" ] && {
  346.         [ "$to_file" ] && {
  347.                 echo
  348.                 echo "Content will be written to $db_dir/$fwd_zone :"
  349.                 echo "----start-------------------------------------"
  350.         }
  351.         cat > ${to_file:-$db_dir/$fwd_zone} <<END
  352. \$TTL    $opt_ttl
  353. @  IN  SOA $ns_host. root.$ns_host. (
  354.                                       $serial_nu ; Serial
  355.                                       28800      ; Refresh
  356.                                       14400      ; Retry
  357.                                       604800     ; Expire
  358.                                       86400 )    ; Minimum
  359. @   IN  NS  $ns_host.
  360. @   IN  MX  10 $ns_host.

  361. ${ns_host%%.*}  IN A            $host_ip
  362. www     IN CNAME        $ns_host.
  363. ftp     IN CNAME        $ns_host.

  364. END
  365.         [ "$to_file" ] && {
  366.                 echo "----end---------------------------------------"
  367.         }
  368.   }

  369.   [ "$rev_zone" ] && {
  370.         [ "$to_file" ] && {
  371.                 echo
  372.                 echo "Content will be written to $db_dir/$rev_zone :"
  373.                 echo "----start-------------------------------------"
  374.         }
  375.         cat > ${to_file:-$db_dir/$rev_zone} <<END
  376. \$TTL    $opt_ttl
  377. @  IN  SOA $ns_host. root.$ns_host. (
  378.                                       $serial_nu ; Serial
  379.                                       28800      ; Refresh
  380.                                       14400      ; Retry
  381.                                       604800     ; Expire
  382.                                       86400 )    ; Minimum
  383. @   IN  NS  $ns_host.

  384. $ns_ptr  IN  PTR $ns_host.

  385. END
  386.         [ "$to_file" ] && {
  387.                 echo "----end---------------------------------------"
  388.         }
  389.   } # end of test
  390. } # end of function

  391. #-- main script --#
  392. do_backup
  393. create_raw
  394. [ "$interact" = true ] && run_intact
  395. [ "$update" = true ] || { check_conf $fwd_zone $rev_zone; mod_conf $fwd_zone $rev_zone; }
  396. mod_rr
  397. [ "$test" = true ] || {
  398.         echo "${0##*/}: Okay, all done!"
  399.         echo "Don't forget to restart your named daemon and check log messages."
  400.         echo "Enjoy!"
  401. }

  402. exit 0
复制代码

[ 本帖最后由 網中人 于 2006-5-15 12:56 编辑 ]
amanl 该用户已被删除
2 [报告]
发表于 2003-12-06 08:32 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
3 [报告]
发表于 2003-12-06 19:53 |只看该作者

[原創] 簡單建立 dns 的 shell script

更新:
# 2) 2003-12-06 v0.2 by netman
#       * improve options selection
# 3) 2003-12-06 v0.3 by netman
#     * improve name server hostname determination


download:
http://www.study-area.org/linux/src/sample_dns.sh.tgz

diff 結果(v0.1 - v0.3):
  1. 66,7c6,7
  2. < # date:       2003-12-06
  3. < # version: v0.3
  4. ---
  5. >; # date:       2003-12-05
  6. >; # version: v.0.1
  7. 32c32
  8. < # 1) 2003-12-05 v0.1 by netman
  9. ---
  10. >; # 1) 2003-12-05 v0.01 by netman
  11. 34,37d33
  12. < # 2) 2003-12-06 v0.2 by netman
  13. < #     * improve options selection
  14. < # 3) 2003-12-06 v0.3 by netman
  15. < #     * improve name server hostname determination
  16. 39,43c35
  17. <
  18. < interact=
  19. < to_file=
  20. < backup=
  21. < update=
  22. ---
  23. >; options=hrstbf
  24. 48a41,43
  25. >; to_file=
  26. >; backup=
  27. >; update=
  28. 57d51
  29. < ns_host=$(hostname -s).$fwd_zone
  30. 66,69d59
  31. <       echo "Usage:"
  32. <       echo -e "\t${0##*/} [-h]"
  33. <       echo -en "\t${0##*/} [-g|-t] [-u] [-b] [-i|"
  34. <       echo "[-f fwd_zone] [-r rev_zone] [-n name_server]]"
  35. 72,76c62,63
  36. <       echo -e "\t-g\trun the script"
  37. <       echo -e "\t-i\tspecify own names interactively"
  38. <       echo -e "\t-f\tname of forward zone"
  39. <       echo -e "\t-r\tname of reverse zone"
  40. <       echo -e "\t-n\tname of name-server"
  41. ---
  42. >;       echo -e "\t-r\trun the script with default values"
  43. >;       echo -e "\t-s\tspecify your own zone names"
  44. 78d64
  45. <       echo -e "\t-u\tforce update db(s)"
  46. 79a66
  47. >;       echo -e "\t-f\tforce update db(s)"
  48. 81,82c68
  49. <       echo -e "\t# $0 -tu"
  50. <       echo -e "\t# $0 -g -f test.cxm -r 3.2.1.in-addr.arpa -n ns.test.cxm"
  51. ---
  52. >;       echo -e "\troot_shell# $0 -tu"
  53. 103c89
  54. < [ $# -eq 0 ] && {
  55. ---
  56. >; echo $@ | grep -q "[^$options-]" || [ $# -eq 0 ] && {
  57. 105c91
  58. <       echo "${0##*/}: Error: missing argument."
  59. ---
  60. >;       echo "${0##*/}: missing argument or invalid options."
  61. 112c98
  62. <       echo "(press Enter for '$2', or press 'n' for none): "
  63. ---
  64. >;       echo "(or press Enter for none): "
  65. 117c103
  66. <               get_zone $1 $2
  67. ---
  68. >;               get_zone $1
  69. 119,123d104
  70. <       if [ -z "$z_name" ]; then
  71. <               z_name=$2
  72. <       elif [ "$z_name" = "n" ]; then
  73. <               z_name=
  74. <       fi
  75. 126,127c107,108
  76. < function run_intact {
  77. <       get_zone forward $fwd_zone
  78. ---
  79. >; function run_spec {
  80. >;       get_zone forward
  81. 129c110
  82. <       get_zone reverse $rev_zone
  83. ---
  84. >;       get_zone reverse
  85. 133,135c114,115
  86. <       echo "(or press Enter for system defaults '$ns_host'): "
  87. <       read _ns_host
  88. <       ns_host=${_ns_host:-$ns_host}
  89. ---
  90. >;       echo "(or press Enter for system defaults): "
  91. >;       read ns_host
  92. 293c273
  93. <               echo "1) delete '$fwd_zone' & '$rev_zone' sections from $named_conf."
  94. ---
  95. >;               echo "1) delete '$zone' sections from $named_conf."
  96. 295c275
  97. <               echo "2) run '${0##*/} -u' to override db files in $db_dir."
  98. ---
  99. >;               echo "2) run '${0##*/} -f' to override db files in $db_dir."
  100. 306,308c286
  101. <               echo
  102. <               echo "Content will be written to $named_conf :"
  103. <               echo "----start-------------------------------------"
  104. ---
  105. >;               echo "---->; Content will be written to $named_conf :"
  106. 317,319d294
  107. <       [ "$to_file" ] && {
  108. <               echo "----end---------------------------------------"
  109. <       }
  110. 324a300
  111. >;   ns_host=${ns_host:-$(hostname -s).$fwd_zone}
  112. 326d301
  113. <   echo $ns_host | grep -q '\.' || ns_host=$ns_host.$fwd_zone
  114. 329,331c304
  115. <               echo
  116. <               echo "Content will be written to $db_dir/$fwd_zone :"
  117. <               echo "----start-------------------------------------"
  118. ---
  119. >;               echo "---->; Content will be written to $db_dir/$fwd_zone :"
  120. 349,351d321
  121. <       [ "$to_file" ] && {
  122. <               echo "----end---------------------------------------"
  123. <       }
  124. 356,358c326
  125. <               echo
  126. <               echo "Content will be written to $db_dir/$rev_zone :"
  127. <               echo "----start-------------------------------------"
  128. ---
  129. >;               echo "---->; Content will be written to $db_dir/$rev_zone :"
  130. 373,375d340
  131. <       [ "$to_file" ] && {
  132. <               echo "----end---------------------------------------"
  133. <       }
  134. 381c346
  135. < while getopts ":hgif:r:n:tub" opt; do
  136. ---
  137. >; while getopts ":$options" opt; do
  138. 384,388c349,350
  139. <               g) : ;;
  140. <               f) fwd_zone=$OPTARG ;;
  141. <               r) rev_zone=$OPTARG ;;
  142. <               n) ns_host=$OPTARG ;;
  143. <               i) interact=true ;;
  144. ---
  145. >;               r) : ;;
  146. >;               s) run_spec ;;
  147. 390d351
  148. <               u) update=true ;;
  149. 391a353
  150. >;               f) update=true ;;
  151. 398,399c360,361
  152. < [ "$interact" = true ] && run_intact
  153. < [ "$update" = true ] || { check_conf $fwd_zone $rev_zone; mod_conf $fwd_zone $rev_zone; }
  154. ---
  155. >;
  156. >; test "$update" = true || { check_conf $fwd_zone $rev_zone; mod_conf $fwd_zone $rev_zone; }
  157. 401c363
  158. < [ "$to_file" ] || {
  159. ---
  160. >; test "$to_file" || {
复制代码

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
4 [报告]
发表于 2003-12-12 21:26 |只看该作者

[原創] 簡單建立 dns 的 shell script

  1. #-- CHANGE LOG --#
  2. # 1) 2003-12-05 v0.1 by netman
  3. #       * first version.
  4. # 2) 2003-12-06 v0.2 by netman
  5. #       * improve options selection, and add:
  6. #               -f, -r, -n
  7. # 3) 2003-12-06 v0.3 by netman
  8. #       * improve name server hostname determination
  9. # 4) 2003-12-07 v0.4 by netman
  10. #       * re-organize options dtermination, and add:
  11. #               -c, -d, -e
  12. # 5) 2003-12-10 v0.5 by netman
  13. #       * bug-fixed to solve:
  14. #               - ip alias address: have primary only
  15. #               - no dns domain: set to test.cxm
  16. #               - no hostname: set to ns1
  17. # 6) 2003-12-12 v0.6 by netman
  18. #       * bug-fixed to solve:
  19. #               - backup dir detection
复制代码

论坛徽章:
0
5 [报告]
发表于 2003-12-13 13:32 |只看该作者

[原創] 簡單建立 dns 的 shell script

好文!

论坛徽章:
0
6 [报告]
发表于 2004-11-03 13:17 |只看该作者

[原創] 簡單建立 dns 的 shell script

k,很好用也。我试了一下。一定要好好的看看哟。

论坛徽章:
0
7 [报告]
发表于 2006-01-24 15:58 |只看该作者
支持奉献

论坛徽章:
0
8 [报告]
发表于 2006-01-24 16:53 |只看该作者
问一下楼主,这个脚本同时支持的BIND8  and 9?

我的DNS服务器,以前的DNS管理员只建立了正解,反解从来没更新过,这脚本能将正解转换成反解吗?

生产机,我不敢测试!

行的话,就太感谢你了!

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
9 [报告]
发表于 2006-01-24 23:45 |只看该作者
呵...
1) 千萬別在 production 機器跑!
2) 其實 script 是幫助那些常"打錯字"的朋友, 若細心, 可以不必參考.
3) script 只是給個 sample, 有很多還要改.
4) 還是要懂得原理才能改的哦.
5) 沒照顧到 chroot 環境, 要自己改哦.
6) bind8 我不清楚, 我當初是在 RH9 上面開發的, 所以針對  bind9.
7) 歡迎改善!  ^_^

论坛徽章:
0
10 [报告]
发表于 2006-12-12 15:17 |只看该作者
太強了,佩服佩服
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP