Some references assume the setting is to be applied to all connected clients so the setup is set on server config. The notes below move the server-side setting to client so it can be set per client/case only.
Setting things up on the server side
The server is Ubuntu using Shorewall as a Firewall. What is needed on the server side is setting NAT from OpenVPN interface to the internet so the internet traffic from vpn can be forwarded to the outside world. Here's what to doAllow IP Forwarding in /etc/shorewall/shorewall.conf :
IP_FORWARDING=Yes
add entry to /etc/shorewall/masq :
eth0 [vpn network IP]
allow traffic from vpn to internet on /etc/shorewall/policy :
vpn net ACCEPT
Client Side
Here's the lines to be added on the client configuration :
redirect-gateway def1
dhcp-option DNS 8.8.8.8
dhcp-option DNS 8.8.4.4
Google DNS used to override whatever exist on client system in case it cannot be accessed through the tunnel.
I make two different .ovpn file with the same keys setting but one has the above setting. This makes it easy to switch between the one for tunneling internet traffic and vpn-lan-only.
That's about it. Below is some source references :
- http://openvpn.net/index.php/open-source/documentation/howto.html#redirect
- http://wiki.debian.org/HowTo/shorewall (part about PAT and NAT)