Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 55.78.16.20
c:\windows\system32\route.exe delete 55.78.16.0
del tmp.cmd
c:\windows\system32\route.exe print | grep.exe -m1 "^ *0.0.0.0" | sed.exe s/\x20\x20*/\t/g | cut.exe -f4 | sed "s/.*/c:\\windows\\system32\\route.exe add 55.78.16.20 mask 255.255.255.255 &/" > tmp.cmd
c:\windows\system32\route.exe print | grep "^ *172.16.0.1" | sed s/\x20\x20*/\t/g | cut -f4 | sed "s/.*/c:\\windows\\system32\\route.exe add 55.78.16.0 mask 255.255.255.0 &/" >> tmp.cmd
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

share|improve this question

2 Answers 2

up vote 0 down vote accepted

First and foremost:

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

Second:

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.

share|improve this answer
    
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 at 0:22

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]

i.e.

route 172.92.3.0 255.255.0.0

Consult this page for details.

http://openvpn.net/index.php/open-source/documentation/howto.html

share|improve this answer

Your Answer

 
discard

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.