openconnect / openconnect-gui

MOVED TO https://gitlab.com/openconnect/openconnect-gui
https://gitlab.com/openconnect/openconnect-gui
GNU General Public License v2.0
1.29k stars 241 forks source link

vpnc-script.js doesn't revert dns settings in windows #233

Open adminios opened 6 years ago

adminios commented 6 years ago

Hello, everyone!

I've use to openconnect and openvpn. It's both clients share the same tun interface and when I switch from openconnect to openvpn, settings for dns servers still from openconnect. I've resolved problem by change 2 lines in vpnc-script.js:

// ReSet Tunnel Adapter IP = nothing echo("Resetting Tunnel Adapter IP"); // exec("netsh interface ip set address " + env("TUNIDX") + " source=static 1.0.0.0 255.255.255.255"); //exec("netsh interface ip delete address " + env("TUNIDX") + " 1.0.0.0"); exec("netsh interface ip set dns " + env("TUNIDX") + " source=dhcp"); exec("netsh interface ip set address " + env("TUNIDX") + " source=dhcp");

That doesn't revert settings back to previous state, but in my opinion, that doesn't need for tun interface :)

horar commented 6 years ago

Hello, thanks for report! Yes, the script is not perfect and there are many open issues. Anyway, the best place to discuss it or propose the fixes/workaround is an upstream openconnect project community. There is no need to register into mailinglist. This project is just about GUI based on top of openconnect library and vpnc scripts.

chchuj commented 6 years ago

I‘ve got the similar problem: openconnect-gui 1.5.3 does not reset both ipv4 and ipv6 address. @adminios 's scripts work for ipv4. I modify it as follows to revert ipv6 address to DHCP

    // ReSet Tunnel Adapter IP = nothing
    echo("Resetting Tunnel Adapter IP");
    //exec("netsh interface ip set address " + env("TUNIDX") + " source=static 1.0.0.0 255.255.255.255");
    //exec("netsh interface ip delete address " + env("TUNIDX") + " 1.0.0.0");
    exec("netsh interface ipv6 delete address " + env("TUNIDX") + " " + env("INTERNAL_IP6_ADDRESS"));
    exec("netsh interface ip set dns " + env("TUNIDX") + " source=dhcp");
    exec("netsh interface ip set address " + env("TUNIDX") + " source=dhcp");
horar commented 6 years ago

180

aminmazi commented 6 years ago

Hi I Replaced the latest script from OpenConnect Web site with the script that exist in release package of this product, It works very good now in windows 10 please update the release package with new script.

horar commented 6 years ago

Oh, ok. As far I remember, the last changes use 2 variant of the vpnc script. The goal is to use original (upstream) version for openconnect.exe and slightly modified (not merged into upstream yet) for GUI.

The reason is very simple. When user get issues with GUI and console doesn't work as well, the problem should be fixed in upstream openconnect project.

May be, I will update notes/hints.