HOSTNAME=dnsmasq
hostnamectl set-hostname "$HOSTNAME"
echo "$HOSTNAME">/etc/hostname
echo "$(grep -E '127|::1' /etc/hosts)">/etc/hosts
echo "$(ip a|grep "inet "|grep -v 127|awk -F'[ /]' '{print $6}') $HOSTNAME">>/etc/hosts
yum -y install dnsmasq
cat >>/etc/dnsmasq.conf<<EOF
resolv-file=/etc/resolv.conf
strict-order
listen-address=127.0.0.1,$(hostname -i)
cache-size=150
log-queries
log-facility=/var/log/dnsmasq.log
address=/vincent.com/192.168.77.190
server=/google.com/8.8.8.8
EOF
echo '192.168.77.100 gitlab.com'>>/etc/hosts
systemctl restart dnsmasq
systemctl enable dnsmasq
配置测试主机的动态域名解析指向该服务器,解析gitlab.com和vincent.com测试
[TOC]