#!/bin/bash Ip_addr=`cat /etc/dnsrecord.txt |awk '{print $1}' |head -1` Check_dns_url(){ grep $1 /etc/dnsrecord.txt >/dev/null if [ $? -ne 0 ];then echo "${Ip_addr} $1 " >> /etc/dnsrecord.txt echo "添加 ${1}到 dns 配置中" else echo "${1} 配置已经存在,不用重复添加。" fi } Check_dns_url cr-ticket.okjiaoyu.cn Check_dns_url cr-spear.okjiaoyu.cn kill -9 `ps -ef |grep dnsmasq |grep -v "grep --color=auto dns" |awk '{print $2}'` >/dev/null 2>&1 /etc/init.d/dnsmasq start >>/dev/null