LAN 或本地家庭網路的 DNS 解決方案

LAN 或本地家庭網路的 DNS 解決方案

這是關於如何提供一個全部的本地家庭網路的解決方案—

  • 我發現了這裡有一個很好的關於dnsmasq配置。
  • 我設法使用上面的文章為本地家庭網路設定dnsmasq伺服器,我也使用同一台伺服器充當 DHCP 伺服器。它在伺服器本身內運作良好。
  • 但是,同一本地家庭網路中的其他筆記型電腦無法對本機進行 DNS 查詢。

即,不知何故,dnsmasq安裝在這些 Ubuntu 筆記型電腦上的程式無法從我的 DNS 伺服器進行 LAN DNS 查詢,即使我已經停用了路由器中的 DNS 服務。即,所有 DNS 服務應該由我的 DNS 伺服器提供。所有這些 Ubuntu 筆記型電腦都包含nameserver 127.0.1.1在該/etc/resolv.conf檔案中,而該檔案又應該快取來自我的 DNS 伺服器的 DNS 解析,對嗎?

更新2:

事實證明,是(Ubuntu 筆記型電腦的)網路管理器導致它們有一個奇怪的127.0.1.1名稱伺服器設定。以下是 dhclient 更新 DHCP 的日誌:

Oct  5 21:07:27 mylptp NetworkManager[854]: <info>  [1507252047.0729] manager: NetworkManager state is now DISCONNECTED

Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9239] device (eth0): Activation: starting connection 'Wired connection 1' (daa2...b460)
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9241] audit: op="connection-activate" uuid="daa2...b460" name="Wired connection 1" pid=4822 uid=0 result="success"
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9243] device (eth0): state change: disconnected -> prepare (reason 'none') [30 40 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9245] manager: NetworkManager state is now CONNECTING
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9253] device (eth0): state change: prepare -> config (reason 'none') [40 50 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9266] device (eth0): state change: config -> ip-config (reason 'none') [50 70 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9270] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9299] dhcp4 (eth0): dhclient started with pid 4826

Oct  5 21:07:42 mylptp dhclient[4826]: DHCPREQUEST of 192.168.2.126 on eth0 to 255.255.255.255 port 67 (xid=0x71e88c46)
Oct  5 21:07:42 mylptp dhclient[4826]: DHCPACK of 192.168.2.126 from 192.168.2.102
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9619] dhcp4 (eth0):   address 192.168.2.126
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   plen 24 (255.255.255.0)
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   gateway 192.168.2.1
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   server identifier 192.168.2.102
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   lease time 4294967295
Oct  5 21:07:42 mylptp avahi-daemon[799]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.126.
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   hostname 'mylptp'
Oct  5 21:07:42 mylptp avahi-daemon[799]: New relevant interface eth0.IPv4 for mDNS.
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   nameserver '192.168.2.102'

Oct  5 21:07:42 mylptp avahi-daemon[799]: Registering new address record for 192.168.2.126 on eth0.IPv4.
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9620] dhcp4 (eth0):   domain name 'my.domain.name'
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9621] dhcp4 (eth0): state changed unknown -> bound
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9630] device (eth0): state change: ip-config -> ip-check (reason 'none') [70 80 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9635] device (eth0): state change: ip-check -> secondaries (reason 'none') [80 90 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9637] device (eth0): state change: secondaries -> activated (reason 'none') [90 100 0]
Oct  5 21:07:42 mylptp NetworkManager[854]: <info>  [1507252062.9638] manager: NetworkManager state is now CONNECTED_LOCAL

Oct  5 21:07:43 mylptp NetworkManager[854]: <info>  [1507252063.0394] manager: NetworkManager state is now CONNECTED_GLOBAL
Oct  5 21:07:43 mylptp NetworkManager[854]: <info>  [1507252063.0395] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
Oct  5 21:07:43 mylptp NetworkManager[854]: <info>  [1507252063.0403] device (eth0): Activation: successful, device activated.

Oct  5 21:10:43 mylptp systemd-resolved[1009]: Switching to DNS server 192.168.2.102 for interface eth0.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (TCP) for DNS server 127.0.1.1.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (UDP) for DNS server 127.0.1.1.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (TCP) for DNS server 127.0.1.1.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (UDP) for DNS server 127.0.1.1.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (TCP) for DNS server 127.0.1.1.
Oct  5 21:10:43 mylptp systemd-resolved[1009]: Using degraded feature set (UDP) for DNS server 127.0.1.1.

為了清晰起見,我將長木頭分成幾組。從日誌中我們可以清楚地看到,dnsmasqDHCP回復中已經推送了正確的DNS伺服器IP位址(第3組,最後​​一行)。然而,systemd-resolved正在運行的是 NetworkManager(或)(第 6 組,第一行)。

為什麼 NetworkManager/systemd-resolved 沒有使用指示使用的正確 DNS 伺服器?我的筆記型電腦使用/查詢本地 DNS 伺服器沒有問題:

me@mylptp$ dig @192.168.2.102 coral
...
;; ANSWER SECTION:
coral.                  0       IN      A       192.168.2.102

;; Query time: 0 msec
;; SERVER: 192.168.2.102#53(192.168.2.102)
;; WHEN: Thu Oct 05 21:16:22 EDT 2017
;; MSG SIZE  rcvd: 50

我所有的機器都是:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 17.04
Release:        17.04
Codename:       zesty

$ ls -l /etc/resolv.conf 
lrwxrwxrwx 1 root root 35 2017-10-05 21:07 /etc/resolv.conf -> /var/run/NetworkManager/resolv.conf

請幫忙。

更新1:

我所缺少的是我“應在 DHCP 回覆中推送 DNS/DHCP 伺服器的正確 IP 位址「,感謝 dirkt 的指導。但是,我該如何做到這一點dnsmasq?我訪問過以下網址,但沒有一個給我答案:

謝謝。

相關內容