Dnsmasq 官网 http://www.thekelleys.org.uk/dnsmasq/doc.html
Unbuntu 安装 Dnsmasq 参见 https://help.ubuntu.com/community/Dnsmasq
介绍
DNSmasq 提供两种服务,每种服务可以单独运行:
- DNS 服务
- DHCP 服务
本地 DNS 缓存可以加速网络访问,因为用户的浏览器不需要对先前查询过域名再次向 DNS服务器查询。
DNCP 允许用户的电脑为同一个无线或有限环境中的其他计算机分配 IP 地址。
安装
1 | $ sudo apt-get install dnsmasq |
配置
dnsmasq 配置文件地址
1 | $ /etc/dnsmasq.conf |
本地 DNS 缓存设置
修改
1 | #listen-address= |
成
1 | listen-address=127.0.0.1 |
接下来修改 /etc/resolv.conf,确保新设置的 DNS 服务器 127.0.0.1 出现在 DNS 服务器列表的顶端。无论何时用户的电脑需要解析一个域名,它会首先请求 dnsmasq (其跑在 127.0.0.1)
1 | cat /etc/resolv.conf |
修改后配置后重启服务生效
1 | $ sudo /etc/init.d/dnsmasq restart |