在绿联云上使用docker 安装pi-hole域名服务器,发现53端口被占用。使用ssh登录nas服务器,查看,
1 2 3 4 5
| sudo netstat -tunlp | grep :53 [sudo] password for zhenlei: tcp 0 0 192.100.2.1:53 0.0.0.0:* LISTEN 1928/dnsmasq tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1657/dnsmasq tcp 0 0 192.100.1.1:53 0.0.0.0:* LISTEN 1892/dnsmasq
|
发现已经安装有dnsmasq,所以,可以直接使用。首先要确定dns服务器的配置文件位置:
1 2 3 4 5 6 7 8
| ps aux | grep dnsmasq dnsmasq 1657 0.0 0.0 41368 2380 ? S Sep27 1:01 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /usr/ugreen/etc/dnsmasq/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --conf-file=/usr/ugreen/etc/dnsmasq/dnsmasq.conf --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d nobody 1842 0.0 0.0 11316 1704 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-nat0.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper root 1843 0.0 0.0 11204 864 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-nat0.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper nobody 1892 0.0 0.0 11316 1848 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-nat1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper root 1893 0.0 0.0 11204 972 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-nat1.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper nobody 1928 0.0 0.0 11316 1972 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-host.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper root 1929 0.0 0.0 11204 804 ? S Sep27 0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/vnet-host.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
|
可以查看配置文件内容:
1
| cat /usr/ugreen/etc/dnsmasq/dnsmasq.conf
|
在目录 /usr/ugreen/etc/dnsmasq/dnsmasq.d/中可以创建自定义的域名:
sudo nano /usr/ugreen/etc/dnsmasq/dnsmasq.d/custom-domains.conf
1 2 3 4 5 6
| # 内网自定义域名解析 address=/nfs.lan/192.168.31.8 address=/myapp.lan/192.168.31.100 address=/k8s2.lan/192.168.31.57 address=/k8s5.lan/192.168.31.78 address=/k8s6.lan/192.168.31.39
|
重启域名服务器:
sudo systemctl restart dnsmasq
测试:
1 2 3
| nslookup nfs.lan Server: 127.0.0.1 Address: 127.0.0.1#53
|
测试外网网址:
1 2 3 4 5
| nslookup jiagoushi.cn
Non-authoritative answer: Name: jiagoushi.cn Address: 47.113.226.153
|
还需要修改/usr/ugreen/etc/dnsmasq/dnsmasq.conf,使其侦听外部请求:
1
| listen-address=127.0.0.1,::1,192.168.31.8
|
修改路由器中DHCP服务器的DNS服务器,改为NAS的ip地址。
可以使用sudo netplay apply更新本地DNS服务器地址。