Opened 6 years ago
Last modified 5 years ago
#1111 closed Bug / Defect
Use iserv to switch interface to DHCP — at Version 7
Reported by: | stipa | Owned by: | stipa |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | Generic / unclassified | Version: | |
Severity: | Patch Queue: In progress | Keywords: | |
Cc: | Selva Nair |
Description (last modified by )
OpenVPN Windows 2.4.6, adapter name is "Ethernet 2".
Mon Sep 17 16:48:10 2018 NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address Ethernet 2 dhcp Mon Sep 17 16:48:10 2018 ERROR: netsh command failed: returned error code 1
Same problem when running this command via admin command problem.
Problem disappears if adapter name is enclosed into quotations.
We should probably use adapter index instead of name, as it has been done for ipv6:
https://sourceforge.net/p/openvpn/mailman/message/34616805/
Change History (7)
comment:1 Changed 6 years ago by
Cc: | snair added |
---|
comment:2 Changed 6 years ago by
Cc: | Selva Nair added; snair removed |
---|
comment:4 Changed 6 years ago by
Yep that might be the case.
Interesting, I cannot reproduce it anymore - now "it just works". Tried reinstall, reboot - works like a charm. Here is log when it works:
Tue Sep 18 10:29:10 2018 [stipakov.fi] Peer Connection Initiated with [AF_INET]xxx.xxx.xxx.xxx:1194 Tue Sep 18 10:29:11 2018 Options error: route parameter network/IP '8.8.8.8/32' must be a valid address Tue Sep 18 10:29:11 2018 open_tun Tue Sep 18 10:29:11 2018 TAP-WIN32 device [Ethernet] opened: \\.\Global\{F9C2860E-B5E8-488B-9ED4-C4E35AEB002C}.tap Tue Sep 18 10:29:11 2018 Notified TAP-Windows driver to set a DHCP IP/netmask of 10.8.0.6/255.255.255.252 on interface {F9C2860E-B5E8-488B-9ED4-C4E35AEB002C} [DHCP-serv: 10.8.0.5, lease-time: 31536000] Tue Sep 18 10:29:11 2018 Successful ARP Flush on interface [167] {F9C2860E-B5E8-488B-9ED4-C4E35AEB002C} Tue Sep 18 10:29:12 2018 do_ifconfig, tt->did_ifconfig_ipv6_setup=0 Tue Sep 18 10:29:17 2018 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Tue Sep 18 10:29:17 2018 Initialization Sequence Completed
and log from yesterday when it didn't work:
Mon Sep 17 16:48:08 2018 [stipakov.fi] Peer Connection Initiated with [AF_INET]xxx.xxx.xxx.xxx:1194 Mon Sep 17 16:48:09 2018 Options error: route parameter network/IP '8.8.8.8/32' must be a valid address Mon Sep 17 16:48:09 2018 open_tun Mon Sep 17 16:48:09 2018 TAP-WIN32 device [Ethernet 2] opened: \\.\Global\{FC42BBF7-7A2A-4818-9284-FA9C5DDBF177}.tap Mon Sep 17 16:48:10 2018 NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address Ethernet 2 dhcp Mon Sep 17 16:48:10 2018 ERROR: netsh command failed: returned error code 1 Mon Sep 17 16:48:15 2018 NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address Ethernet 2 dhcp Mon Sep 17 16:48:15 2018 ERROR: netsh command failed: returned error code 1 Mon Sep 17 16:48:20 2018 NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address Ethernet 2 dhcp Mon Sep 17 16:48:20 2018 ERROR: netsh command failed: returned error code 1 Mon Sep 17 16:48:25 2018 NETSH: C:\WINDOWS\system32\netsh.exe interface ip set address Ethernet 2 dhcp Mon Sep 17 16:48:26 2018 ERROR: netsh command failed: returned error code 1 Mon Sep 17 16:48:30 2018 NETSH: command failed Mon Sep 17 16:48:30 2018 Exiting due to fatal error
I'll keep an eye on it and debug further if manage to reproduce it again.
comment:5 Changed 6 years ago by
You can't reproduce it anymore, because there is no more "netsh set ... dhcp" call - it succeeded once when run as admin, and since then, the interface is on DHCP.
Now OpenVPN just tells the TAP driver "use that IP for DHCP" and this does not need admin privs.
comment:6 Changed 6 years ago by
Indeed, when I removed DHCP (switched from "Obtain an IP address automatically" to "Use the following IP address" in UI), I see problem again.
Let me look into switching interface to DHCP with iserv. I'll change ticket title.
comment:7 Changed 6 years ago by
Description: | modified (diff) |
---|---|
Summary: | Netsh command fails if adapter name contains whitespace → Use iserv to switch interface to DHCP |
Adapter index sounds like a good idea, but in this case I assume it's something else.
TAP adapter names have always had spaces in them ("LAN-Verbindung 4"), and the argv handling on windows does not need quotes (because it knows which parts are one exevp[] element). Actually, when I added quotes to one of the netsh invocations, it failed, because there is no shell in between which will handle the quoting/whitespace splitting.
If you look at tun.c, netsh_ifconfig(), you can see that we never quote the ifname...
In your case, I assume the problem is that openvpn does not have admin privs, and we don't use the interactive service to turn on DHCP. This is a patch that would indeed be useful :-) ("if (service_pipe) then send message to iserve to switch interface to DHCP").