From: Simon Rozman via Openvpn-devel Date: Thu, 24 Sep 2020 06:44:51 +0000 (+0200) Subject: netsh: Clear existing IPv6 DNS servers before configuring new ones X-Git-Tag: v2.5_rc2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77c62003c263304f8b411d664cf56179f8d4df08;p=thirdparty%2Fopenvpn.git netsh: Clear existing IPv6 DNS servers before configuring new ones When there are no IPv6 DNS published, the adapter state is not sanitized and might contain IPv6 DNS server from a previous session. netsh_ifconfig_options() clears DNS servers for IPv4 already. Signed-off-by: Simon Rozman Acked-by: Lev Stipakov Message-Id: <20200924064452.1001-2-simon@rozman.si> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21078.html Signed-off-by: Gert Doering (cherry picked from commit dd754221024cf60226ebaa679ec65ccc23f4e402) --- diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c index 8fd3229f1..b1cd7a1b5 100644 --- a/src/openvpn/tun.c +++ b/src/openvpn/tun.c @@ -5281,7 +5281,6 @@ ip_addr_member_of(const in_addr_t addr, const IP_ADDR_STRING *ias) * Set the ipv6 dns servers on the specified interface. * The list of dns servers currently set on the interface * are cleared first. - * No action is taken if number of addresses (addr_len) < 1. */ static void netsh_set_dns6_servers(const struct in6_addr *addr_list, @@ -5291,6 +5290,13 @@ netsh_set_dns6_servers(const struct in6_addr *addr_list, struct gc_arena gc = gc_new(); struct argv argv = argv_new(); + /* delete existing DNS settings from TAP interface */ + argv_printf(&argv, "%s%s interface ipv6 delete dns %lu all", + get_win_sys_path(), + NETSH_PATH_SUFFIX, + adapter_index); + netsh_command(&argv, 2, M_FATAL); + for (int i = 0; i < addr_len; ++i) { const char *fmt = (i == 0) ?