I'm trying for several days now to solve my problem. I have been using openvpn for windows for quite a while and after replacing windows with ubuntu 13.10, I was happy to see that openvpn is available for ubuntu as well.

I copied my settings from windows and in /var/log/syslog I see that my connection is successfully created. However, no matter what I do, I'm unable to set routes. In windows, this was simply done by script that worked as follows (ip addresses slightly differ since I have to keep them private):

c:\windows\system32\route.exe delete
c:\windows\system32\route.exe delete
del tmp.cmd
c:\windows\system32\route.exe print | grep.exe -m1 "^ *" | sed.exe s/\x20\x20*/\t/g | cut.exe -f4 | sed "s/.*/c:\\windows\\system32\\route.exe add mask &/" > tmp.cmd
c:\windows\system32\route.exe print | grep "^ *" | sed s/\x20\x20*/\t/g | cut -f4 | sed "s/.*/c:\\windows\\system32\\route.exe add mask &/" >> tmp.cmd

After connection was set and above script was executed, connections to my servers went through VPN, while all other went normally.

Since this script uses grep, sed and cut, I figured I can easily "translate" it to linux. And I did it, except for the fact that I'm a bit unsure how to use route command to set my connection properly.

P.S. I also tried setting VPN using network manager, but the same question appears: how to add routes?

Thx in advance


First and foremost:

You have been using GNU tools on windows? Like WTH man.


Basically you have two ways to achieve the same thing.

The first is to use the ip command. You would do something like ip route add .... though I'm kinda oldschool and dislike ip so I'm not too sure about how would you do that but man ip will certainly help you there.

The second is to use the older route command. With this you can modify the kernel's routing table. Issuing man route will pretty much tell you what you need to do, but for the sake of completeness it should be something like route add <target IP you want to reach> <interface that you want the target to be reached>. You can set the target IP to entire subnets, but then you will have to add in a gateway for that too. (And set up a route to that gateway.)
Oh and you can check your interfaces with both ip and ifconfig.

Let me know how it works out for you.

  • actually, ifconfig did the job - told me what should i select as gateway for that particular address i was wondering about. thx. – playcat Jan 18 '14 at 0:22
  • What is WTH? google.com/search?q=gnu+wth – Bruno Bronosky Jan 31 '17 at 16:16

On OpenVPN you can accomplish this in three ways:

  1. Server pushes the route to ALL the clients. You do this by putting the route command in the server.conf file, on the server
  2. Server pushes the route to a single client. You do this by putting the route command in a client-specific file in what's known as the client-config folder on the server
  3. Client sets up the route. You do this by putting the route into your client config (ovpn on windows) file

In all three cases it looks like this:

route [routeaddress] [netmask]



Consult this page for details.


  • 2
    This is the right answer. It should be selected as such. – Bruno Bronosky Jan 31 '17 at 16:18

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.