想必很多人手头上都有那么一两个开发板吧,树莓派啊香橙派啊nano pi啊什么的。而且这些开发板好玩不贵,很适合我们做各种折腾。arm以它的稳定性其实能很好地充当服务器这一职能。不多说,马上开始我们新一轮的折腾吧!
其实dnsmasq在官方的软件库里就有了,我们很容易就能安装好。只需要输入:

sudo apt-get install -y dnsmasq

即可。
下面我们就需要配置DNSMASQ了,配置文件一般位于路径/etc/dnsmasq.conf。基本上配置文件内容如下所示:

# 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
all-servers
server=101.132.183.99
server=119.29.29.29
server=180.76.76.76
server=193.112.78.75
server=223.5.5.5
server=101.6.6.6
server=1.0.0.1
 
# 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

这里的DNS可以按照自己的实际情况来修改。如果需要更大的缓存,直接修改cache-size的值即可。国内基本上可以通用我这套配置。
修改完成后输入:

sudo service dnsmasq restart

如果你的系统有内置的iptables可以通过以下命令开放53端口

iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT

重启dnsmasq进程应用修改即可。在路由器里或者在电脑上修改dns的地址为你的开发板的地址即可。
如果一切正常但不能使用,考虑关闭开发板的防火墙。Ubuntu关闭方法:

ufw disable
Last modification:December 31, 2018
If you think my article is useful to you, please feel free to appreciate