我正在尝试使用教程让 dnsmasq 在 CentOS 7 中运行 https://linuxhint.com/configure_dnsmasq_centos/
以下是相关的配置文件
/etc/dnsmasq.conf
port=5353
domain-needed
bogus-priv
strict-order
domain=mallet.lan
expand-hosts
/etc/resolv.conf
Generated by NetworkManager
search home
nameserver 192.168.1.100
nameserver 192.168.0.1
nameserver 127.0.0.1
nameserver 8.8.8.8
/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.100 ns.mallet.lan
192.168.1.50 www.mallet.lan
以下是相关命令的输出
dnsmasq 处于活动状态并正在运行
$ systemctl status dnsmasq
● dnsmasq.service - DNS caching server.
Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2023-10-28 17:01:45 AEDT; 1min 46s ago
Main PID: 28656 (dnsmasq)
Tasks: 1
CGroup: /system.slice/dnsmasq.service
└─28656 /usr/sbin/dnsmasq -k
Oct 28 17:01:45 localhost.localdomain systemd[1]: Started DNS caching server..
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: started, version 2.76 cachesize 150
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: compile time options: IPv6 GNU-getopt DBus no-i18n IDN DHCP DHCPv6 no-Lua TFTP no-con...inotify
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: reading /etc/resolv.conf
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: using nameserver 8.8.8.8#53
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: using nameserver 192.168.0.1#53
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: using nameserver 192.168.1.100#53
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: using nameserver 127.0.0.1#53
Oct 28 17:01:45 localhost.localdomain dnsmasq[28656]: read /etc/hosts - 4 addresses
enp6so 设置为 ns.mallet.lan 的地址
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:e0:4c:68:d1:1f brd ff:ff:ff:ff:ff:ff
inet 192.168.1.100/24 brd 192.168.1.255 scope global noprefixroute enp6s0
valid_lft forever preferred_lft forever
inet6 fe80::db4:c8af:1a4b:ee6b/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 90:e6:ba:c8:f8:a0 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.40/24 brd 192.168.0.255 scope global noprefixroute dynamic enp2s0
valid_lft 50110sec preferred_lft 50110sec
inet6 fe80::1683:279d:161c:b014/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:a6:6d:7e brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:a6:6d:7e brd ff:ff:ff:ff:ff:ff
ns.mallet.lan 返回 ping
$ ping ns.mallet.lan
PING ns.mallet.lan (192.168.1.100) 56(84) bytes of data.
64 bytes from ns.mallet.lan (192.168.1.100): icmp_seq=1 ttl=64 time=0.089 ms
64 bytes from ns.mallet.lan (192.168.1.100): icmp_seq=2 ttl=64 time=0.049 ms
^Z
[6]+ Stopped ping ns.mallet.lan
使用 dig 查询时未显示预期的答案部分
$ dig ns.mallet.lan
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.15 <<>> ns.mallet.lan
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 27114
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;ns.mallet.lan. IN A
;; AUTHORITY SECTION:
. 86390 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2023102701 1800 900 604800 86400
;; Query time: 16 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sat Oct 28 16:51:49 AEDT 2023
;; MSG SIZE rcvd: 117
$ dig 192.168.1.100
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.15 <<>> 192.168.1.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 56801
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;192.168.1.100. IN A
;; AUTHORITY SECTION:
. 86363 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2023102701 1800 900 604800 86400
;; Query time: 16 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Sat Oct 28 16:54:46 AEDT 2023
;; MSG SIZE rcvd: 117
*NXDOMAIN returned when queried with nslookup*
$ nslookup ns.mallet.lan
Server: 8.8.8.8
Address: 8.8.8.8#53
** server can't find ns.mallet.lan: NXDOMAIN
$ nslookup 192.168.1.100
** server can't find 100.1.168.192.in-addr.arpa.: NXDOMAIN
因此..
ns.mallet.lan 应答 ping 但返回 NXDOMAIN 并且没有带有 dig 的应答部分。nslookup
返回 NXDOMAIN。
我在这里做错了什么?
我认为这行
Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; disabled; vendor preset: disabled)
可能意味着需要启用该服务,但我查看了教程
https://linuxhint.com/configure_dnsmasq_centos/
并且它有相同的输出。