Mac OS X comes with two firewalls installed by default. One visible is System Preferences is the application firewall and won't be of any help in this case.
The other is a packet filtering firewall called
pf, however it does not offer a GUI.
Basically you need to block all outgoing connections on your regular network interface except the one to the VPN server and pass all traffic on the VPN interface.
The configuration of the firewall is in the
/etc/pf.conf file. You need to add at least the following rules (the following assumes your regular interface is
en0 and VPN's
block out on en0 from any to any
pass out on en0 from any to <vpn_server_IP>
pass out on tun0 from any to any
Remember that the last rule "wins".
After modifying the contain file run to load the rules:
pfctl -f /etc/pf.conf
To disable the firewall run:
The rules above are minimal ones for the purpose you specified, you might also need to add a rule to access your local network through the regular interface. Also they block DNS, so you'd need to specify the IP of the VPN server not its DNS name when connecting.