
假設我有這個私有主機名dev.private.example.com
,只能透過 VPN 連接在私有網路中訪問,並且我有可以prod.example.com
透過網路存取的主機名稱。我有 DNS 伺服器來解析私有主機名,然後我可以使用公用 DNS 伺服器(google、cloudflare 等)來解析公用主機名稱。
我想設定 dnsmasq(讓我知道是否有其他工具),以便它將查詢 DNS 伺服器的私人主機名,如果它是另一個主機名,那麼它將透過公共 DNS 伺服器進行解析
我該怎麼做呢?
答案1
這對我有用
編輯/etc/dnsmasq.conf
並將其放入文件中
conf-dir=/etc/dnsmasq.d/,*.conf
然後在conf目錄下建立一個文件/etc/dnsmasq.d/private.example.com.conf
並在文件內容中加入以下內容
#dont use hosts nameservers
no-resolv
#use following default nameservers
server=1.1.1.1
server=8.8.8.8
strict-order
#serve all *.private.example.com queries using a specific nameserver
server=/private.example.com/140.82.113.1
server=/private.example.com/140.82.113.2
其中以下是名稱伺服器140.82.113.1
和140.82.113.2
解析私有主機名
然後重新啟動dnsmasq
service restart dnsmasq
現在任何私有主機名稱 *.private.example.com 將使用這些名稱伺服器來解析!
和繁榮!