bind添加域名解析脚本
#!/bin/sh CONFIG_FILE="/path/to/zonefile" read -p "输入域名: " domain read -p "输入要解析的IP: " ip serial=$(head -3 $CONFIG_FILE | tail -1 | tr -cd "[0-9]") echo "序号:$serial" let "new_serial=$serial+1" echo "新的序号:$new_serial" read -p "按任意键继续..." aaa echo "备份配置文件" cp $CONFIG_FILE ${CONFIG_FILE}_$( date "+%Y%m%d%H%M%S") echo "开始添加域名" echo -e "$domain\tIN\tA\t$ip" >> l$CONFIG_FILE echo "显示添加结果:" tail -1 $CONFIG_FILE sed -i "s/$serial/$new_serial/" $CONFIG_FILE echo "显示修改后的序号:" head -7 $CONFIG_FILE echo "重新加载配置文件..." rndc reload