安装 dnsmasq
sudo apt-get install dnsmasq
配置 dnsmasq
vi /etc/dnsmasq.d/test.conf # 随便开一个文件
填入:
cname=from.gaubee.com,to.gaubee.com
修改本地 dns 配置:
vi /etc/resolv.conf # 添加一行 nameserver 127.0.0.1
最终我自己本地这个文件是这样的
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf: # [network] # generateResolvConf = false nameserver 127.0.0.1 nameserver 172.19.208.1
最后启动 dnsmasq 即可:
/etc/init.d/dnsmasq start
它会监听本地 53 断开(DNS 服务的端口),如果报端口占用。那么查看一下占用程序
sudo lsof -i -P -n | grep LISTEN