Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an OpenVPN connection (point to point). When program connects to server it gets IP and Gateway dynamically, from server.

I need to make windows add route to my secure server through given gateway. For example open VPN gives IP: 192.168.100.2, gw: 192.168.100.1. My secure server's IP is 10.0.0.1, i need to make them connected. My router, he's also working as open vpn server (MIKROTIK) see both of them, i can connect them using command route add 10.0.0.1 mask 255.255.255.255 192.168.1.1, but openVPN can give different IP and gateway for different user. I want to make windows add route to DHCP specified gateway. Virtual adapter's interface number is 19, i've tried to add route like this: route add 10.0.0.1 mask 255.255.255.255 0.0.0.0 metric 1 if 19, but if i do route print after that it shows that my route has ~31 metric, that's more than metric for my internet connection, and it's impossilbe to reach this route.

sorry for long post, i don't know how to explain better (if i knew, i'd asked google).

p.s. as temporary solution i've made openvpn server give same ip and gateway for two users, but it's not a good solution.

UPD: User on windows 7 machine don't have administrator rights, so OpenVPN is unable to add routes.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Your best bet is to create an "on-connect" script that adds your routes as needed. There is no way for you to create a "blanket-route" that would cover every possible IP in the subnet.

as far as how to construct your "on-connect" script... you can read another question that has been answered here:

http://askubuntu.com/questions/28733/how-do-i-run-a-script-after-openvpn-has-connected-successfully

share|improve this answer
    
yes, i thinked of it, but the second problem i've forgot to mention is that - user, running openVPN client have limited rights, so openvpn don't have rights to add routes.. –  Stalker May 15 '12 at 18:44
1  
You may need to put the user openVPN is running as into the "Network Configuration Operators" group. This should give the user enough rights to add/delete routes without being a full admin. –  TheCompWiz May 15 '12 at 18:54
    
Thank you! I've totally forgot about this option. –  Stalker May 18 '12 at 10:31
add comment

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.