dnsmasq - 防止解析不存在的主機

dnsmasq - 防止解析不存在的主機

我已經在 ubuntu 實例上安裝了 dnsmasq DNS 伺服器,並在配置中新增了網域名稱。它運作正常,只是它解析未知主機的方式與解析網域的方式相同。

這是我的配置:

/etc/dnsmasq.conf

# domain name
domain=example.com
local=/example.com/

address=/example.com/127.0.0.1 
listen-address=127.0.0.1

/etc/主機

127.0.0.1 localhost
172.217.16.195 www.google.com
10.10.1.x testhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

我已經在「範例」實例上安裝了 nginx 伺服器,因此當我向連接埠 80 發送 GET 請求時,我希望看到預設頁面,並且這按計劃工作:

curl example.com

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...

在「testhost」實例上,我安裝了傳回「hello world」的簡單伺服器,這也運作正常。

curl testhost.example.com

hello world

但是,當我請求不存在的主機時,它會被重定向到“範例”主機: curl random-string-asfasfasfasf.example.com

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...

我怎樣才能防止這種行為?

相關內容