安装之前最好先, sudo apt-get update , sudo apt-get upgrade
-
sudo apt-get install dnsmasq
-
grep -v '^#' /etc/dnsmasq.conf | grep -v '^$' 查看dnsmasq.conf文件中生效的语句(就是没有加#的语句)
-
sudo nano /etc/dnsmasq.conf-----------完成修改,如下所有内容,那个ip地址该自己的
resolv-file=/etc/resolv.dnsmasq.conf
strict-order
listen-address=127.0.0.1,192.168.5.175
addn-hosts=/etc/dnsmasq.hosts
cache-size=10000
log-queries
conf-dir=/etc/dnsmasq.d
conf-dir=/etc/dnsmasq.d,.bak
conf-dir=/etc/dnsmasq.d/,*.conf
-
新建两个文件 /etc/resolv.dnsmasq.conf 和 /etc/dnsmasq.hosts
可以直接nano创建 /etc/resolv.dnsmasq.conf 该文件是指定上游dns服务器地址的参数,如nameserver 114.114.114.114 /etc/dnsmasq.hosts 该文件是自定义解析文件,如192.168.5.168 tomcp.com
运行,查看状态
-
sudo systemctl restart dnsmasq
-
sudo systemctl status dnsmasq
测试
nslookup
查找局域网内所有地址指令,包括mac,ip
arp -a
查看IP地址对应的电脑名
nbtstat -a IP地址