Skip to content

Apply “default-domain” to client

Summary

In server ocserv.conf uncomment "default-domain" and add value, but at client site, vpnc-script.js not implement it. I try to add one line in vpnc-script.js to implement it.

Version of the software & operating system

openconnect-gui 1.6.1, windows 10 22H2

Steps to reproduce

server site uncomment "default-domain" and add value. In client site, the value will appear in "CISCO_DEF_DOMAIN" environment variable. vpnc-script.js not implement it, I found two way to apply it to client network interface. and i expect developer will merge the code into windows install package.

1, Add one line to vpnc-script.js (attachment line 229)vpnc-script.js:

  run("wmic nicconfig where \"(IPEnabled=TRUE) and (Description='OpenConnect Tunnel')\" call SetDNSDomain "+env("CISCO_DEF_DOMAIN"));

2, Add one line to vpnc-script.js to call powershell:

  run("powershell \"c:/Program Files/OpenConnect-GUI/MyDnsDoMain.ps1 \""+env("CISCO_DEF_DOMAIN"));

MyDnsDoMain.ps1 content

param( $myDomain )

$netIf = Get-WmiObject Win32_NetworkAdapterConfiguration -filter "IPEnabled = $TRUE and Description='OpenConnect Tunnel'"

$netIf.SetDnsDomain( $myDomain )

MyDnsDoMain.ps1 END

MyDnsDoMain.ps1

Note 1: Powershell maybe not run, because of Execution_Policies.

Note 2: If editing text file with notepad in windows other than english version (for example , i'm using simplify chinese windows 10), text-file's codepage will be turn from ANSI to UTF-8, may cause fail to run. Win 7 or below did not change codepage.

Edited by Liu QuanYue