I would like to be able to connect to my home network and access my music there via mpd. I have a VPN network setup at home, so I can securely connect to machines in my home network from outside with minimal security risks. But while at work, I don't want to disturb the usual routing for connecting to the Internet etc.

How should I set up the OpenVPN client configuration file so that I am able to access machines on my home network from outside, without altering Internet routing?

[Alternatively, is there a better way to connect to mpd from outside a network without creating security risks?]

[Edit: my current client conf file looks like this:

dev tun
proto udp
remote some.web.site.com 1194
resolv-retry infinite
ns-cert-type server
key-direction 1
cipher AES-128-CBC
verb 1
mute 20 



Set your client to have a route parameter to only your home LAN. For example if your home LAN was, the the parameter would look like this in the .conf file:


and dont push any routes from the server onto the client. This way when the tunnel comes up all you will route through it is the network you put in the route parameter.


Since your server has these push lines:

push "redirect-gateway def1 bypass-dhcp" 
push "dhcp-option DNS" 
push "dhcp-option DNS"

You need to delete them to have the desired effect you are looking for. It would be even better to have two instances of openvpn running on your server. One with the actual config and one with a modified one that you will use when connected from the office. Just have the two configs listening on different ports and connect to them as desired.

For example on the actual one put below parameter at end of server config:

port 1200

and on the modified one put:

port 1201

Then your client can connect to either port depending on your needs.

  • Currently my client .conf files don't have any lines starting with route.... Does OpenVPN default to pushing all of the routes whenever there is no explicit specification of routes? – emacsomancer Feb 7 '15 at 17:44
  • 1
    If you have something like this ->push "redirect-gateway" on your server then yes. So the answer is, it depends on your server config. – Ricardo Feb 7 '15 at 18:06
  • Thanks. My server config has the following "push" lines: push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS" push "dhcp-option DNS" – emacsomancer Feb 7 '15 at 20:02
  • 1
    I have updated my answer with your server config details. – Ricardo Feb 7 '15 at 21:06

Risking digging up this thread from the dead (it showed up in related).

Actually, it is pretty simple. You do not have to do anything on the server.

add the following lines to your .ovpn configuration file:

route vpn_gateway #for single IP address
route   vpn_gateway #for /24 range

This way, the default route will not change, but the traffic flowing toward those IP addresses will go through VPN.

More information about this can be found in the official OpenVPN manual.


  When used with --client or --pull, accept options pushed by server EXCEPT
  for routes, block-outside-dns and dhcp options like DNS servers.When used 
  on the client, this option effectively bars the server from adding routes
  to the client’s routing table, however note that this option still allows
  the server to set the TCP/IP properties of the client’s TUN/TAP interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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