OpenVPN connected but not internet access on the client

internetopenvpnvpn

I've setup OpenVPN following this tutorial, and everything works fine except that I don't have an internet connection on the client while connected to VPN.

http://www.howtoforge.com/internet-and-lan-over-vpn-using-openvpn-linux-server-windows-linux-clients-works-for-gaming-and-through-firewalls

My VPS server config is as follows (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

My client config is as follows (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

I've turned off the firewall on the server for testing purposes (it doesn't help), and tried both wired and wireless connecting on the client.

I've tried many Google results… but nothing seems to help.

Can you help me?

Thanks so far…

Best Answer

If you're pushing all Internet traffic through the VPN like it's configured to (the redirect-gateway directive), you also need to tell the server to route the traffic with iptables like so:

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

Adjust to your requirements, but that's the jist of it.