路由器不提供/转发网络上其他机器上运行的 DNS 服务器信息

路由器不提供/转发网络上其他机器上运行的 DNS 服务器信息

我正在努力实现以下目标目标

但是无法通过附加路由器以与从 raspi 板载 WIFI 芯片接入点相同的方式访问我的网络应用程序。

Raspbian Stretch 9.4

dnsmasq -v
Version de Dnsmasq 2.76  Copyright (c) 2000-2016 Simon Kelley
Options à la compilation IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth DNSSEC loop-detect inotify

/etc/dnsmasq.conf

#########################################################
# DNS
#########################################################
interface=wlan0
interface=eth0
listen-address=127.0.0.1
listen-address=192.168.42.1
listen-address=192.168.1.100

bind-dynamic
#server=8.8.8.8

# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts
domain=local

# Add local-only domains here, queries in these domains are answered
# from /etc/hosts or DHCP only.
local=/local/

# Never forward plain names (without a dot or domain part)
#domain-needed

# Never forward addresses in the non-routed address spaces.
bogus-priv

#########################################################
# DHCP
#########################################################
# DO NOT PROVIDE DHCP ON ETHERNET, AS PI IP IS DHCP ASSIGNED BY AND RESERVED ON ADDITIONAL ROUTER (192.168.1.100)
# ADDITIONAL ROUTER IS IN CHARGE OF DHCP ASSIGNING IPs TO CLIENTS, ONLY DNS SHOULD BE PROVIDED WHEN REQUESTED ON ETH0
no-dhcp-interface=eth0

#Allow more IP than needed to allow max MAC address on WIFI board chip (32 on raspi 3B)
dhcp-range=192.168.42.2,192.168.42.50,255.255.255.0,6h

# GATEWAY
# Override the default route supplied by dnsmasq, which assumes the
# router is the same machine as the one running dnsmasq.
dhcp-option=3,192.168.42.1

#dns server address delivered to clients
dhcp-option=6,192.168.42.1

/etc/hosts

127.0.0.1       myHost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters
127.0.1.1       myHost
192.168.42.1    myHost
192.168.42.1    myHost.local
192.168.42.1    box
192.168.42.1    box.local
192.168.42.1    box.myHost.com
192.168.42.1    myHost.com
192.168.42.1    www.myHost.com

/etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0

nohook wpa_supplicant
interface wlan0
static ip_address=192.168.42.1/24
static routers=192.168.42.1
static domain_name_servers=192.168.42.1

# protect resolv.conf
nohook resolv.conf

答案1

好的,所以我忽略了一个显而易见的点:DNS 为 raspi OWN wifi 网络提供解析,即 192.168.42.1... 无法从外部网络访问!因此,在 /etc/hosts 文件中添加相同的信息,并使用保留的 192.168.1.100 地址和相同的主机名,我可以让它工作......

尽管如此,我很确定这不是正确的/学术的,但在现实生活中它确实有用。如果有任何 DNS/网络管理员/专家路过,请随时纠正我。

干杯

相关内容