RPI DNS Server
将Raspberry配置成DNS server
Install the dnsmasq
$ sudo apt-get install dnsmasq
Configure the
/etc/dnsmasq.conf
,add the parameters:resolv-file=/etc/resolv.dnsmasq #strict-order cache-size=1500 listen-address=127.0.0.1,192.168.52.1 address=/myapp.com/192.168.52.1
Edit the
/etc/udhcpd.conf
and change the line,opt dns 8.8.8.8 4.2.2.2 #192.168.10.2 192.168.10.10
to
opt dns 192.168.52.1
Configure the network
allow-hotplug wlan0 iface wlan0 inet static address 192.168.52.1 netmask 255.255.255.0 gateway 192.168.52.1 network 192.168.52.0 broadcast 192.168.52.255 dns-nameservers 192.168.52.1 up iptables-restore < /etc/iptables.ipv4.nat
/etc/resolv.conf
,由于此文件为系统启动重新设置文件,需要添加以下文件:- 在
/etc
目录下新增resolv.conf.head
,内容如下:
# Google DNS #nameserver 8.8.8.8 #OpenDns Servers #nameserver 208.67.222.222 #nameserver 208.67.220.220 nameserver 192.168.52.1
- 在
Restart service
sudo service dnsmasq restart
此时,访问myapp.com 就可以解析到 192.168.52.1
可通过ping myapp.com
进行测试