首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使DNSMasq向没有域的Windows主机提供DNS服务?

问如何使DNSMasq向没有域的Windows主机提供DNS服务?
EN

Unix & Linux用户
提问于 2018-08-31 02:26:22
回答 1查看 9.9K关注 0票数 1

我安装了一个DNSMasq的Ubuntu16.04主机(10.0.10.2),它只为DNS服务,在同一个子网上安装了几个Windows主机,在同一个子网上安装了另外几个Linux主机。我的默认网关是为DNS服务器分发DHCP和10.0.10.2。

Windows框没有定义DNS搜索后缀或域,但我希望它们能够解析我在DNSMasq服务器上的/etc/host中定义的主机,而不必指定域或搜索后缀,但事实证明这是很困难的。Wireshark认为,在执行ping或尝试导航到Linux主机上的web服务时,Windows主机总是希望附加.local。

我的/etc/host文件如下:

代码语言:javascript
复制
127.0.0.1 localhost
10.0.10.2 box-linux-0 box-linux-0.local
10.0.10.3 box-linux-1 box-linux-1.local
10.0.10.3 box-linux-2 box-linux-2.local
10.0.10.7 box-windows-0 box-windows-0.local
10.0.10.5 box-windows-1 box-windows-1.local

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

我的DNSMasq配置是:

代码语言:javascript
复制
strict-order
port=53
resolv-file=/etc/resolv.conf
log-queries
log-facility=/var/log/dnsmasq.log

我的resolv.conf是:

代码语言:javascript
复制
nameserver 127.0.0.1
nameserver 8.8.8.8

是否有什么东西让Windows主机能够解析box 0,box 1,box 2?

EN

回答 1

Unix & Linux用户

发布于 2018-08-31 03:17:29

您的resolv.conf不应该有外部DNS服务器,以确保dnsmasq正在解析所有DNS请求。改为:

代码语言:javascript
复制
nameserver 127.0.0.1

要允许解析外部DNS名称,请使用dnsmasq作为全局DNS服务器,方法是告诉它使用某些外部DNS服务器。添加到DNSmasq配置文件:

-服务器直接指定上游服务器的IP地址。

代码语言:javascript
复制
server=8.8.8.8

要使dnsmasq仅解析实际可能是全局dns名称的名称,请添加到DNSmasq配置文件中:

代码语言:javascript
复制
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv

为了确保本地名称由/etc/host解析,添加到DNSmasq文件中:

代码语言:javascript
复制
# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
local=/local./

您可以尝试此选项(可能有用与否):

代码语言:javascript
复制
# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts

# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
#     as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
#    domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
domain=local
票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/465901

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档