
我正在嘗試讓 dnsmaq 和 OpenVPN 在 DigitalOcean 上協同工作。我想建立一個 VPN,它將以 *.local 結尾的請求轉發到 Droplet,而其他請求則由 Google DNS 解析。
這是我的/etc/dnsmasq.conf
:
address=/.local/10.8.0.1
resolv-file=/etc/resolv.dnsmasq
listen-address=127.0.0.1
listen-address=10.8.0.1
bind-interfaces
server=8.8.8.8
server=8.8.4.4
這是我的/etc/openvpn/server.conf
:
dev tun
proto udp
port 1194
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
push "route 10.8.0.0 255.255.255.0"
push "dhcp-option DNS 10.8.0.1"
push "redirect-gateway def1 bypass-dhcp"
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
此時我已經連接到 VPN 並且它可以工作了。我可以打開每個網站,除了以 *.local 結尾的網站(出現 ERR_NAME_NOT_RESOLVED)。
編輯:
這是我的/etc/resolv.conf
文件:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 2001:4860:4860::8844
nameserver 2001:4860:4860::8888
nameserver 8.8.8.8
安裝 dnsmasq 後,nameserver 127.0.0.1
但每次我重新啟動伺服器時,它都會回到上面的狀態。
答案1
搜尋了一下,發現我沒有在防火牆上開啟DNS伺服器連接埠。這就是問題所在。