Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I configure Mac OS X such that it can only allow an internet connection (both downloads and uploads) through a given VPN connection?

If the VPN connection disconnects, the internet should stop working.

I need to do this due to security reasons. Sometimes I use ISPs that I have no reason to trust. Especially on wifi hotspots.

How do I do this? I'm sure there is nothing I can do through the Mac OS X GUI, but is there any hack I can do via the Terminal?

share|improve this question

migrated from Aug 9 '11 at 6:48

This question came from our site for professional and enthusiast programmers.

If you are making a VPN connection, isn't the default route for all traffic to use that connection?

Anyway, set a default route to the VPN. Traffic should stop when the link dies.

It's late and I might not be interpreting your question clearly :D

share|improve this answer
That's all well and fine while the VPN connection is active. However, if the VPN connection prematurely disconnects (and while I'm away from my computer and thus don't notice it), the internet connection will fall back to my insecure default non-VPN connection. That's what I want to avoid. – Enchilada Aug 13 '11 at 13:37
up vote 0 down vote accepted

I doubt this is possible with the VPN stuff in OS X. Correct me if I'm wrong.

However, I was able to solve this by using OpenVPN and Tunnelblick has capabilities for running scripts when the VPN connection dies. So I just run a script that turns off the Ethernet/AirPort when the VPN dies. Seems to be working.

share|improve this answer
I've found a way using pf.conf that may interest you. Details are here. – Nick Sep 8 '12 at 11:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .