如何在树莓派上搭建DNS域名查询服务器

通过下面的命令安装 dnsmasq:

sudo apt-get install -y dnsmasq

启动dnsmasq服务:

sudo service dnsmasq start

编辑 /etc/dnsmasq.conf 文件更改dnsmasq配置信息:

# Dnsmasq.conf for raspberry pi
# /etc/dnsmasq.conf
# http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq.conf.example
 
# Set up your local domain here
domain=raspberry.local
resolv-file=/etc/resolv.dnsmasq
min-port=4096
server=8.8.8.8
server=8.8.4.4
 
# Max cache size dnsmasq can give us, and we want all of it!
cache-size=10000
 
# Below are settings for dhcp. Comment them out if you dont want
# dnsmasq to serve up dhcpd requests.
# dhcp-range=192.168.0.100,192.168.0.149,255.255.255.0,1440m
# dhcp-option=3,192.168.0.1
# dhcp-authoritative

重启dnsmasq服务:

sudo service dnsmasq restart

如需添加静态dns 指向,则在 /etc/dnsmasq.d/ 路径下新建立static.conf 文件,内容如下:

address=/dustit.me/127.0.0.1

完成后记得重启一下dnsmasq服务。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据