一、安装dns服务
1)yum安装
yum install dnsmasq -y
2)配置本地的 dns 解析
# 设置上游DNS,毕竟你的Dns只是个代理 cat >/etc/resolv.dnsmasq <<EOF nameserver 114.114.114.114 nameserver 8.8.8.8 EOF
3)设置需要解析的域名
cat >/etc/dnsmasqhosts <<EOF 192.168.44.11 demo-init.opendevops.cn 192.168.44.11 mg.opendevops.cn 192.168.44.11 task.opendevops.cn 192.168.44.11 gw.opendevops.cn 192.168.44.11 cmdb2.opendevops.cn 192.168.44.11 kerrigan.opendevops.cn 192.168.44.11 tools.opendevops.cn 192.168.44.11 cron.opendevops.cn 192.168.44.11 dns.opendevops.cn EOF
4)配置 dns 的配置文件
# 注意下一步是覆盖你本机的DNS,建议把你的DNS地址加在/etc/resolv.dnsmasq 里面 echo "nameserver $LOCALHOST_IP" > /etc/resolv.conf echo "resolv-file=/etc/resolv.dnsmasq" >> /etc/dnsmasq.conf echo "addn-hosts=/etc/dnsmasqhosts" >> /etc/dnsmasq.conf
5)启动服务
/bin/systemctl enable dnsmasq.service /bin/systemctl start dnsmasq.service systemctl status dnsmasq if [ $? == 0 ];then echo -e "