0

I have a few Windows 7/8 clients connecting to a Linux OpenVPN Server (tap). I'd like to set the clients' DNS and WINS servers upon connection. The OpenVPN isn't acting as DHCP server; there is an independent DHCP sever in the network.

The most reasonably way to achieve that is through DHCP. However, the DHCP server is quite basic, and I cannot configure these parameters in the DHCP server itself. (And I'd rather not to replace the DHCP server, it'd be too complicated)

I've tried push "dhcp-option DNS 10.0.0.101" and push "dhcp-option WINS 10.0.0.101", but it didn't help. The clients just ignored these. I assume that these options are treated only when the OpenVPN server is also the DHCP server. (am I correct?)

Setting DNS and WINS manually with windows "Network Conncections" GUI is working, but I want something automatic (as much as possible).

My next try was running a script on the client machine. I'm usually a Linux scripter; however, something that simple should be feasible even with Windows, isn't it?

First approach,PowerShell (run as Administrator)

 $wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ServiceName = 'tap0901'"
 echo $wmi
 $wmi.SetWinsServer("10.0.0.101","")

Strangely, I couldn't find the equivalent command for setting the DNS Server.

And that without mentioning the PowerShell complication with the default ExecutionPolicy of Restricted, which makes it quite user-unfriendly as automatic solution for the end-user.

Another approach I checked was netsh. However, in all the examples I saw with Google (such as http://community.spiceworks.com/scripts/show/2195-set-ip-address-subnet-gateway-dns-and-wins-server-all-windows-os-also-works-with-runas) they didn't refer to the Adapter name (I'm not sure that it's the correct term) - 'tap*', but to some arbitrary "Local Area Connection*", which will probably different in each machine.

So, how to continue? What's the recommended way to solve this?

EDIT

Here's my client.ovpn file:

client
pull
# from http://serverfault.com/questions/110281/openvpn-client-on-windows-7-cannot-add-route-from-config-script
script-security 2 system
dev tap
proto tcp-client
remote A.B.C.D 443
resolv-retry infinite
nobind
ca ..
cert ..
key ..
comp-lzo
verb 5
Zvika
  • 223
  • 5
  • 10
  • Your `push` directive should work...Can you show us the `.ovpn` config file you use for clients ? – krisFR Mar 18 '14 at 12:56
  • @user2196728, what do you say about my client.ovpn? – Zvika Mar 18 '14 at 18:25
  • i've done some search, and maybe you have to specify `push "redirect-gateway"` in your `openvpn` server config file to be able to "push dhcp-option DNS..." – krisFR Mar 18 '14 at 20:24
  • @user2196728, But I don't want "Routing all client traffic (including web-traffic) through the VPN"... Can you provide a link to the relation between `push "redirect-gateway" ` and `push dhcp-option DNS` ? – Zvika Mar 19 '14 at 17:52
  • Ok, but at least you could give it a one shot try if you can. I cannot provide such a link because it was just a guess, i've read nothing that clearly mention this relation. By the way you could check client and server logs to find some clues about why options are not pushed. My own setup includes `redirect_gateway` + fixed IPs and my DNS push works fine, but not sure about the relationship... – krisFR Mar 19 '14 at 18:05

0 Answers0