[原創] 簡單建立 dns 的 shell script域名服务器教程
|
| 论文作者:佚名 论文来源:不详 论文发布时间:2006-6-19 17:58:20 论文发布人:chjchjchj |
减小字体
增大字体
摘要:[原創] 簡單建立 dns 的 shell script 常碰到一些朋友抱怨說 linux 的 dns 很難設。 但經我個人觀察,100% 都是打錯字或格式疏忽而已~~~~ ^_^
這裡我寫了隻 shell script ,可以幫助建立簡單的正解及反解檔, 然後將剩下的"簡單"的部份,則自己來修改了...
download: http://www.study-area.org/linux/src/sample_dns.sh.tgz
初版原始碼: [code:1:212a63ac08]#!/bin/bash set -u
# purpose: make a sample dns for RedHat like system # author: netman<netman@study-area.org> # date: 2003-12-05 # version: v.0.1
#-- CAVEATE --# # 1) script has been tested only on RedHat 8.x/9.0 platform. # 2) needs root privilege to run. # 3) only one forward zone and one reverse zone will be created. # if no specified zone names are given, script will assume to # use the current DNS domain(using text.cxm instead if not found) for # forward zone's name, and the Class-C ipv4 subnet of current IP for # reverse zone's name. # 4) the script can NOT determine whether you have the proper delegation, # you should manually delete ANY non-authorized zone settings. # 5) only followint Resource Record will be create by this script: # * SOA (both forward & reverse) # * NS (both forward & reverse) # * MX (forward only) # * A (forward only) # * CNAME (www & ftp, forward only) # * PTR (reverse only) # 6) a backup for named.conf and db directory will be made to /root/backup. # backup will be performed once during the first running only, # unless -b options is given. # 7) absolutely NO WARRANTY while running this script.
#-- CHANGE LOG --# # 1) 2003-12-05 v0.01 by netman # * first version.
options=hrstbf
named_conf=/etc/named.conf db_dir=/var/named bak_dir=/root/backup wtty=$(ps | grep $$ | tail -n 1 | awk '{print $2}') to_file= backup= update=
#-- get zone info --# fwd_zone=$(hostname -d) fwd_zone=${fwd_zone:-test.cxm} host_if=eth0 host_ip=$(ifconfig | grep -A1 $host_if | awk '/inet/{print $2}' | sed 's/^.*://') host_ip=${host_ip:-192.168.1.1} rev_zone="$(echo ${host_ip%.*} | awk -F. '{print $3"."$2"."$1}').in-addr.arpa" ns_ptr=${host_ip##*.} serial_nu=$(date +%Y%m%d)01 opt_ttl=86400
function print_usage { echo "-------------------------------------------------------------" echo "Script Name:" echo -e "\t${0##*/}" echo "Options:" echo -e "\t-h\tprint this help" echo -e "\t-r\trun the script with default values" echo -e "\t-s\tspecify your own zone names" echo -e "\t-t\ttest only" echo -e "\t-b\tforce backup" echo -e "\t-f\tforce update db(s)" echo "Example:" echo -e "\troot_shell# $0 -tu" echo "-------------------------------------------------------------" exit 0 }
function print_choice { echo echo "Please select one:" echo "h): to print HELP." echo "t): to TEST the script only." echo "q): to QUIT." echo -n 'Your choice? ' read action case $action in h|H) print_usage ;; t|T) exec $0 -t ;; q|Q) echo; exit 0 ;; *) print_choice ;; esac }
echo $@ | grep -q "[^$options-]" || [ $# -eq 0 ] && { echo echo "${0##*/}: missing argument or invalid options." print_choice }
function get_zone { echo echo "Which name y
|
|
|
|
|
|
|
| ∷相关技术评论 |
(评论内容只代表网友观点,与本站立场无关!) [查看发表评论...] | |
|
|
| |
站内广告 |
| |
|
站内搜索 |
| |
栏目导航 |
| |
|
|
本月热门 |
| |
|
|
本日热门 |
| |
|
|
|