Server Fault is a question and answer site for system and network administrators. 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

I'm using OpenVPN through Tunnelblick on MacOS X Lion.

I need to set specific DNS (with local IP, which works only when VPN is up) for the duration of this VPN session only.

I do not have access to the OpenVPN server configuration. Only client config. Also, DNS from the server doesn't work.

So it works like this: I connect to VPN, go the Network preferences and manually set DNS. After VPN is disconnected, I switch back to default. It works, but it needs to be automatic.

After some exploration I found that OpenVPN up- and down- scripts might help me with that. Unfortunately, I haven't found any specific documentation about how exactly it can be done.

How it can or can't be done? Any advice would be appreciated!

share|improve this question
I've also considered ControlPlane app - no luck figuring it out :-) – Stanislav Shabalin Aug 12 '12 at 13:11
@quanta Nice, but I'll have to list all domains - that's too much :-( (We have a few dozens of domains in our developer infrastructure.) – Stanislav Shabalin Aug 12 '12 at 14:38
up vote 24 down vote accepted

try adding:

# put actual dns name here
dhcp-option DNS

to your client's config

share|improve this answer
Thank you! It worked. I've stumbled upon push "dhcp-option DNS" regarding server configs, didn't know how to convert it to client configs. Thanks again :-) – Stanislav Shabalin Aug 12 '12 at 15:09
you're welcome. tbh i did not try that but now i know it actually works ;] – pQd Aug 12 '12 at 17:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.