Change in openvpn[master]: tun.c: set IPv4 address temporary on Windows
A message that is not in the archive (sent off-list or not yet received): gerrit.1765353329000.I07311f397e6cd278b90c33f024e927c282cd03e4@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email
to review the following change.
Change subject: tun.c: set IPv4 address temporary on Windows
......................................................................
tun.c: set IPv4 address temporary on Windows
Use store=active to set IPv4 address temporary so that it will be removed on reboot. This makes the behavior consistent with deletion and IPv6, where we already use store=active.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface
GitHub: https://github.com/OpenVPN/openvpn/issues/915
---
M src/openvpn/tun.c
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/30/1430/1
src/openvpn/tun.c +2 -2
@@ -5119,8 +5119,8 @@ }else { -/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 */ -argv_printf (&argv,"%s%s interface ip set address %lu static %s %s" ,get_win_sys_path (), +/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 store=active */ +argv_printf (&argv,"%s%s interface ip set address %lu static %s %s store=active" ,get_win_sys_path (),NETSH_PATH_SUFFIX , adapter_index,print_in_addr_t (ip,0 , &gc),print_in_addr_t (netmask,0 , &gc));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I07311f397e6cd278b90c33f024e927c282cd03e4
Gerrit-Change-Number: 1430
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: plaisthos, stipa.
cron2 has posted comments on this change by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email )
Change subject: tun.c: set IPv4 address temporary on Windows
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I07311f397e6cd278b90c33f024e927c282cd03e4
Gerrit-Change-Number: 1430
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: stipa <[email protected]...>
Gerrit-Comment-Date: Wed, 10 Dec 2025 07:58:44 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 tun.c: set IPv4 address temporary on Windows
In reply to a message not in the archiveFrom: Lev Stipakov <[email protected]...>
Use store=active to set IPv4 address temporary so that it will be removed on reboot. This makes the behavior consistent with deletion and IPv6, where we already use store=active.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface
GitHub: https://github.com/OpenVPN/openvpn/issues/915
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1430
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1430
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/tun.c +2 -2
@@ -5119,8 +5119,8 @@ }else { -/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 */ -argv_printf (&argv,"%s%s interface ip set address %lu static %s %s" ,get_win_sys_path (), +/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 store=active */ +argv_printf (&argv,"%s%s interface ip set address %lu static %s %s store=active" ,get_win_sys_path (),NETSH_PATH_SUFFIX , adapter_index,print_in_addr_t (ip,0 , &gc),print_in_addr_t (netmask,0 , &gc));
[Openvpn-devel] [PATCH applied] Re: tun.c: set IPv4 address temporary on Windows
Arguably this is a bug, but it's a bug in a dark corner of a niche use case - *if* running OpenVPN on windows with privileges, *and* not using DHCP but "ip-win32 netsh", *and* still using IPv4, then we install the IPv4 address using no explicit "store=<nnn>" command - which defaults to "permanent" (unlike "ip address add ..." on a unixoid system, which is never persistent) - so the IPv4 address sticks across reboots.
First mistake... and then, on session end, we try to remove it with "store=active" - which makes it go away *up to the next reboot*, and then it's back, possibly interfering with future uses.
So this patch adds the "store=active" to the netsh.exe call inside openvpn.exe for IPv4. This will fix it for all future assignments, but not for "existing leftovers" - these will need to be fixed manually (once).
(One of the grand plans for 2.8 is "rip out all this from openvpn, only support a single method, which is IPAPI via interactive service" - but for 2.7 and 2.6, this is a bug that needs to be fixed short term)
The backport to 2.6 is trivial, though "cherrypick" does not work out of the box due to the clang-reformat of the function call.
This said, I have not actually *tested* it, beyond "does it compile" - the issue is clearly understood, the fix is clear, and it's just a string change (as far as openvpn is concerned).
Your patch has been applied to the master and release/2.6 branch (bug).
commit 93c9b47cb0916c16ef76e6ecb5bf3f2ba7d267aa (master) commit 3aacb621b56015f92cc0ae79987fa29c33842a2d (release/2.6)
Author: Lev Stipakov Date: Wed Dec 10 08:59:00 2025 +0100
tun.c: set IPv4 address temporary on Windows
Signed-off-by: Lev Stipakov <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1430
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34975.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by stipa. ( http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: tun.c: set IPv4 address temporary on Windows
......................................................................
tun.c: set IPv4 address temporary on Windows
Use store=active to set IPv4 address temporary so that it will be removed on reboot. This makes the behavior consistent with deletion and IPv6, where we already use store=active.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface
GitHub: fixes OpenVPN/openvpn#915
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1430
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34975.html
---
M src/openvpn/tun.c
1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/30/1430/2
src/openvpn/tun.c +2 -2
@@ -5119,8 +5119,8 @@ }else { -/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 */ -argv_printf (&argv,"%s%s interface ip set address %lu static %s %s" ,get_win_sys_path (), +/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 store=active */ +argv_printf (&argv,"%s%s interface ip set address %lu static %s %s store=active" ,get_win_sys_path (),NETSH_PATH_SUFFIX , adapter_index,print_in_addr_t (ip,0 , &gc),print_in_addr_t (netmask,0 , &gc));
Signature · 13 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newpatchset Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I07311f397e6cd278b90c33f024e927c282cd03e4 Gerrit-Change-Number: 1430 Gerrit-PatchSet: 2 Gerrit-Owner: stipa <[email protected]...> Gerrit-Reviewer: cron2 <[email protected]...> Gerrit-Reviewer: plaisthos <[email protected]...> Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email )
Change subject: tun.c: set IPv4 address temporary on Windows
......................................................................
tun.c: set IPv4 address temporary on Windows
Use store=active to set IPv4 address temporary so that it will be removed on reboot. This makes the behavior consistent with deletion and IPv6, where we already use store=active.
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/netsh-interface
GitHub: fixes OpenVPN/openvpn#915
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1430
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg34975.html
---
M src/openvpn/tun.c
1 file changed, 2 insertions(+), 2 deletions(-)
src/openvpn/tun.c +2 -2
@@ -5119,8 +5119,8 @@ }else { -/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 */ -argv_printf (&argv,"%s%s interface ip set address %lu static %s %s" ,get_win_sys_path (), +/* example: netsh interface ip set address 42 static 10.3.0.1 255.255.255.0 store=active */ +argv_printf (&argv,"%s%s interface ip set address %lu static %s %s store=active" ,get_win_sys_path (),NETSH_PATH_SUFFIX , adapter_index,print_in_addr_t (ip,0 , &gc),print_in_addr_t (netmask,0 , &gc));
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1430?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I07311f397e6cd278b90c33f024e927c282cd03e4
Gerrit-Change-Number: 1430
Gerrit-PatchSet: 2
Gerrit-Owner: stipa <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>