Opened 22 months ago

Closed 8 months ago

#1111 closed Bug / Defect (fixed)

Use iserv to switch interface to DHCP

Reported by: stipa Owned by: stipa
Priority: major Milestone:
Component: Generic / unclassified Version:
Severity: Patch Queue: In progress Keywords:
Cc: selvanair

Description (last modified by stipa)

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 (10)

comment:1 Changed 22 months ago by Gert Döring

Cc: snair added

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").

comment:2 Changed 22 months ago by Gert Döring

Cc: selvanair added; snair removed

comment:3 Changed 22 months ago by tincantech

cc

comment:4 Changed 22 months ago by stipa

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 22 months ago by Gert Döring

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 22 months ago by stipa

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 22 months ago by stipa

Description: modified (diff)
Summary: Netsh command fails if adapter name contains whitespaceUse iserv to switch interface to DHCP

comment:8 Changed 22 months ago by selvanair

Severity: Not set (select this one, unless your'e a OpenVPN developer)Patch Queue: In progress

comment:9 Changed 22 months ago by Gert Döring

commit b4fc8bbd6b1d0211dd6982c4accedfbe4ae7e3ed (master)
commit 78d4f0ad106720d8988e144f6d30ec11d84dee2f (master)
Author: Selva Nair
Date: Tue Oct 2 16:01:13 2018 -0400

Enable dhcp on tap adapter using interactive service

Signed-off-by: Selva Nair <selva.nair@…>
Acked-by: Lev Stipakov <lstipakov@…>
Acked-by: Gert Doering <gert@…>
Message-Id: <1538510474-27602-2-git-send-email-selva.nair@…>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17517.html
Signed-off-by: Gert Doering <gert@…>

... tested and works :-)

Fix will show up in the next 2.4.x release, which is due "later this year".

I'm closing this ticket now since there is nothing more to do. Thanks.

comment:10 Changed 8 months ago by Gert Döring

Resolution: fixed
Status: assignedclosed

It's in 2.4.7, I think. One year ago.

Really closing this ticket now!

Note: See TracTickets for help on using tickets.