首 页 教育新闻课件中心论文中心教学教案试题中心语文专题综合下载技术教程公务员  
设为首页
加入收藏
联系我们
您当前的位置:中国教育资源网 -> 技术教程 -> 网络相关 -> 服务器 -> 域名服务器 -> 技术内容 退出登录 用户管理

[原創] 簡單建立 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
[] [返回上一页] [打 印] [收 藏]  
 ∷相关技术评论  (评论内容只代表网友观点,与本站立场无关!) [查看发表评论...]
 
 中国教育资源网免费技术教程下载中心-站内广告 站内广告 中国教育资源网免费技术教程下载中心-站内广告 
 中国教育资源网站内搜索 站内搜索 中国教育资源网站内搜索 
 

   
 中国教育资源网免费技术教程下载中心-栏目导航 栏目导航 中国教育资源网免费技术教程下载中心-栏目导航 
· Windows 9XMEXP · Windows NT20002003
· LinuxBSD · 系统综合
· IISApache · 硬件技术
· Web服务器 · FTP服务器
· 邮件服务器 · 域名服务器
· Windows服务器 · 代理服务器
· 服务器综合
 
中国教育资源网免费技术教程下载中心-相关教程  相关技术 中国教育资源网免费技术教程下载中心-相关教程
· [图文] 下拉菜单全攻略之&#
· [图文] javascript实现
· PHP/MySQL Search E
· 适合本blog的一个精
· [图文] 网页javascript
· 网页验证(使用正则
· javascript实现
· javascript实现
· 关于javascript
· 用javascript脚
 中国教育资源网免费技术教程下载中心-本月热门教程 本月热门 中国教育资源网免费技术教程下载中心-本月热门教程 
 
 中国教育资源网免费技术教程下载中心-本日热门论文 本日热门 中国教育资源网免费技术教程下载中心-本日热门论文 
 
关于本站 - 网站帮助 - 免费课件 - 美容 - 绿色软件 - 软件下载 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 网站留言
浙ICP备06010405号 Email:cnkjz@163.com 技术支持:名流设计
版权所有 Copyright© 2002-2004 名流