用dnsmasq搭建dns服务器
1 安装dnsmasq sudo apt-get install dnsmasq 说明:/etc/resolv.conf是默认的文件,记录的是本机器的上游dns服务器。
2 设置dnsmasq配置文件 dnsmasq的默认配置文件是/etc/dnsmasq.conf
sudo vim /etc/dnsmasq.conf 设置dnsmasq的监听的地址,也就是本机ip地址
# Or which to listen on by address (remember to include 127.0.0.1 if # you use this.) listen-address=127.0.0.1, {ip_address} #({ip_address}添加自己的本机器ip地址) 测试dns服务器可以用dig(Domain Information Groper)和nslookup
若没有这些命令,先安装
ubuntu sudo apt-get install dnsutils debian apt-get update apt-get install dnsutils centos yum install bind-utils dig @dns服务器的ip 网站域名 dig @1.0.0.1 www.bing.com nslookup 网站域名 dns服务器的ip nslookup www.bing.com 1.0.0.1 如果不想读取本机hosts,可以设置no-hosts
# If you don't want dnsmasq to read /etc/hosts, uncomment the # following line.……