I found openvpn environment variables cannot invoke by .bat script in windows, 
neither $dev nor %dev%.

So I got network adapter id from /openvpn/log/client.log, and use id for netsh 
cmd.

/openvpn/config/client_up.bat script

@echo off
for /f "delims=[] tokens=2,3*" %%i in ('type ..\log\client.log ^|findstr 
/C:"Successful ARP Flush on interface"') do set id=%%i

netsh interface ipv6 set dnsservers %id% static 2001:4860:4860::8888 primary

this worked.

Maybe helpful.

Thanks Gert for idea.
 
From: Gert Doering
Date: 2016-05-17 15:22
To: x...@biigroup.cn
CC: Gert Doering; openvpn-users
Subject: Re: Re: [Openvpn-users] How OPENVPN server push IPv6 DNS to client?
Hi,
 
On Tue, May 17, 2016 at 11:05:46AM +0800, x...@biigroup.cn wrote:
> Hi Gert, I knew on Linux box I can invocate $dev in up script, but on windows 
> netsh up script, environment variables unworked.
> 
> How can I put device name in netsh cmd?
> 
> just like:
> netsh interface ipv6 set dnsservers "????????? 2" static 2001:4860:4860::8888 
> primary
> 
> actually device name and quotes in script. but using $dev failed.
 
Try without quotes.  netsh and quoting is a bit funny.
 
Windows environment variables can be used with '%', like this: %dev%
(though I've never tried --up scripts on windows yet)
 
gert
-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             g...@greenie.muc.de
fax: +49-89-35655025                        g...@net.informatik.tu-muenchen.de
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users

Reply via email to