我正在尝试使用 OpenVPN 社区版创建分割隧道。
我想在服务器上而不是客户端上执行此操作,这样我就可以根据需要轻松添加和删除路由。这是在 Ubuntu 20.04 上
我的当前(非分割隧道配置)运行良好:
port 1194
proto udp
dev tun
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.0.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
push "redirect-gateway def1 bypass-dhcp"
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_sdafasdf.crt
key server_sdafasdf.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
log-append /var/log/openvpn/auth.log
plugin /usr/lib/openvpn/openvpn-auth-ldap.so /etc/openvpn/auth-ldap.conf
verify-client-cert optional
verb 3
这是我的拆分隧道配置,它不起作用。编辑:我可以 ping 8.8.8.8,但似乎 DNS 不适用于此配置。
port 1194
proto udp
dev tun
user nobody
group nogroup
persist-key
persist-tun
keepalive 10 120
topology subnet
server 10.8.0.0 255.255.0.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
#push "redirect-gateway def1 bypass-dhcp"
push "route XX.XX.XX.0 255.255.255.0" #anonymized
dh none
ecdh-curve prime256v1
tls-crypt tls-crypt.key
crl-verify crl.pem
ca ca.crt
cert server_sdafasdf.crt
key server_sdafasdf.key
auth SHA256
cipher AES-128-GCM
ncp-ciphers AES-128-GCM
tls-server
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
client-config-dir /etc/openvpn/ccd
status /var/log/openvpn/status.log
log-append /var/log/openvpn/auth.log
plugin /usr/lib/openvpn/openvpn-auth-ldap.so /etc/openvpn/auth-ldap.conf
verify-client-cert optional
verb 3
客户端配置:
client
proto udp
explicit-exit-notify
remote XX.XX.XX.XX 1194 #anonymized
dev tun
resolv-retry infinite
pull
nobind
persist-key
persist-tun
remote-cert-tls server
verify-x509-name server_sdafasdf name
auth SHA256
auth-nocache
cipher AES-128-GCM
tls-client
tls-version-min 1.2
tls-cipher TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
ignore-unknown-option block-outside-dns
setenv opt block-outside-dns # Prevent Windows 10 DNS leak
verb 3
register-dns
auth-user-pass
答案1
我解决了这个问题。
我需要推动 DNS 路由。
push "route 8.8.4.4 255.255.255.255"
这是因为
setenv opt block-outside-dns
在 Windows 上,block-outside-dns 会执行此操作。因此需要路由。
答案2
您的配置与我的配置差别不大,在我的配置中,无论是公共 IP 还是私有 IP,使用大量“路由推送”后一切都能正常工作。可能是您的网络拓扑/配置(防火墙、路由等)中的其他因素阻止您访问您指定的路由?