
我已經按照本教學設定了 OpenVPN,一切正常,只是在連接到 VPN 時客戶端上沒有網路連線。
我的VPS伺服器配置如下(Ubuntu):
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key /etc/openvpn/easy-rsa/keys/server.key
dh /etc/openvpn/easy-rsa/keys/dh1024.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client
push "redirect-gateway local def1"
#set the dns servers
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
log-append /var/log/openvpn
comp-lzo
plugin /usr/lib/openvpn/openvpn-auth-pam.so common-auth
我的客戶端配置如下(Windows 7):
dev tun
client
proto udp
remote XXX.XXX.XXX.XXX 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert stefan.crt
key stefan.key
comp-lzo
verb 3
auth-user-pass
redirect-gateway local def1
我出於測試目的關閉了伺服器上的防火牆(這沒有幫助),並在客戶端上嘗試了有線和無線連線。
我已經嘗試了很多谷歌結果......但似乎沒有任何幫助。
你能幫助我嗎?
到目前為止謝謝...
答案1
如果您像配置的那樣透過 VPN 推送所有網路流量(指令redirect-gateway
),那麼您也需要告訴伺服器使用 iptables 路由流量,如下所示:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
根據您的要求進行調整,但這就是要點。