新的 openvpn 服务器客户端可以 ping 第 2 层,但不能 ping 第 3 层(DNS)

新的 openvpn 服务器客户端可以 ping 第 2 层,但不能 ping 第 3 层(DNS)

我正在尝试配置一个新的 openvpn 服务器,我的客户端可以连接到该服务器,ping 4.2.2.2,但在第 3 层(DNS)失败。

错误:

ping google.com
temporary failure in name resolution

服务器配置:

mode server
tls-server
port 1194
proto udp
dev tun

ca      /etc/openvpn/server/ca.crt
cert    /etc/openvpn/server/issued/server.crt
key     /etc/openvpn/server/private/server.key
dh      /etc/openvpn/server/dh.pem

server 10.9.8.0 255.255.255.0
ifconfig-pool-persist ipp.txt
keepalive 10 120
comp-lzo         # Compression - must be turned on at both end
persist-key
persist-tun
#status /var/log/openvpn-status.log
verb 1  # verbose mode
user nobody
group nogroup
client-config-dir /etc/openvpn/ccd
client-to-client
push "redirect-gateway def1"
push "redirect-gateway bypass-dhcp"
push "route 192.168.1.0 255.255.255.0"
push "dhcp-option DNS 137.220.63.245"
#push "dhcp-option DNS 4.2.2.2"
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf

log /var/log/openvpn/openvpn.log

iptables:

root@vultr:~# cat /etc/iptables/rules.v4 
# Generated by iptables-save v1.8.7 on Wed Jun 16 04:19:35 2021
*mangle
:PREROUTING ACCEPT [2774:359035]
:INPUT ACCEPT [1375:169341]
:FORWARD ACCEPT [1396:189514]
:OUTPUT ACCEPT [629:154223]
:POSTROUTING ACCEPT [2025:343737]
COMMIT
# Completed on Wed Jun 16 04:19:35 2021
# Generated by iptables-save v1.8.7 on Wed Jun 16 04:19:35 2021
*filter
:INPUT ACCEPT [1375:169341]
:FORWARD ACCEPT [1396:189514]
:OUTPUT ACCEPT [629:154223]
COMMIT
# Completed on Wed Jun 16 04:19:35 2021
# Generated by iptables-save v1.8.7 on Wed Jun 16 04:19:35 2021
*nat
:PREROUTING ACCEPT [93:6515]
:INPUT ACCEPT [19:1048]
:OUTPUT ACCEPT [1:76]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o enp1s0 -j MASQUERADE
COMMIT
# Completed on Wed Jun 16 04:19:35 2021

客户端配置:

root@hvm-debian01:/etc/openvpn# cat /etc/openvpn/client.conf
client
remote 1.1.1.1
dev tun
nobind
tls-client
cert /etc/openvpn/client2.crt
key /etc/openvpn/client2.key
ca /etc/openvpn/ca.crt
comp-lzo
verb 5
ping-restart 60
log /var/log/openvpn/openvpn.log

如何让 openvpn 为我的客户端支持 dns?

systemctl restart systemd-resolved

没有帮助

连接后,我的

/etc/resolv.conf

似乎更新正确。

root@hvm-debian01:/etc/openvpn# cat /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 137.220.63.245
nameserver 192.168.1.1

答案1

将推送 DNS 从 137.220.63.245 更改为 4.2.2.2 可解决该问题。

dig google.com. @137.220.63.245

来自客户的揭露了这个问题。

相关内容