-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inclusion of wsl-vpnkit #262
Comments
It looks like wsl-vpnkit could be useful for other distros with nix installed as well. I suggest you try to get the derivation merged into nixpkgs instead of here. Once it's in there, we could add the systemd service here |
As i'm on a coporate Laptop with Windows and VPN i'm very grateful for wsl-vpnkit :) Thanks for adding it to nixpkgs. |
adding # see https://github.com/sakai135/wsl-vpnkit/blob/5084c6d/wsl-vpnkit.service
systemd.services.wsl-vpnkit = {
enable = true;
description = "wsl-vpnkit";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${pkgs.wsl-vpnkit}/bin/wsl-vpnkit";
Restart = "always";
KillMode = "mixed";
};
}; |
I explicitly didn't add |
Is this still needed? There are some experimental network options in the latest WSL which sound like they make wsl-vpnkit obsolete (I haven't used it myself, so I can't test) |
Yes potentially, but there is a while until we get there. I tried to test this new feature, but it requires a bleeding edge windows version which is not under my control where needed.
|
Friendly ping @terlar As of
❯ cat /etc/wsl.conf
wsl-vpnkit stopped working.
Which configuration would reenable it ? EDIT: Running directly though does seem to prove it is still executable
|
@573 Yes, this is an issue with the newer WSL (since 2.0.5) requires you to use I am currently running this override until this gets merged:
|
Thank you so much, @terlar this now explains why I was able to even run
or just plain
but not the exact same commands via systemd service. The env variable (set in NixOS-WSL correctly) was just not exported then. Glad, you figred it out, even tried setting absolute paths and |
I have tested the new options:
Unfortunately neither worked well with my company VPN and I still had to resort to Since WSL 2.0.14, the mentioned issue with I have also added a custom service like this: {
systemd.services = {
wsl-vpnkit-auto = {
enable = cfg.autoVPN;
description = "wsl-vpnkit";
path = [pkgs.iputils];
script = ''
has_internet () {
ping -q -w 1 -c 1 8.8.8.8 >/dev/null
}
has_company_network () {
ping -q -w 1 -c 1 ${cfg.checkURL} >/dev/null
}
is_active_wsl-vpnkit () {
systemctl is-active -q wsl-vpnkit.service
}
main () {
if is_active_wsl-vpnkit; then
if has_internet && ! has_company_network; then
echo "Stopping wsl-vpnkit..."
systemctl stop wsl-vpnkit.service
fi
else
if ! has_internet; then
echo "Starting wsl-vpnkit..."
systemctl start wsl-vpnkit.service
fi
fi
}
while :
do
main
sleep 5
done
'';
wantedBy = ["multi-user.target"];
};
wsl-vpnkit = {
enable = true;
description = "wsl-vpnkit";
serviceConfig = {
ExecStart = "${pkgs.wsl-vpnkit}/bin/wsl-vpnkit";
Type = "idle";
Restart = "always";
KillMode = "mixed";
};
};
};
} This way I can automatically connect to the wsl-vpnkit when needed and shut it down when off VPN. I can try to clean it up and make a PR if people think it is useful. At least for me it had made the VPN situation within WSL seemless. |
@terlar thank you so much! I would really appreciate a PR for this. |
Any updates on this? I have seen the wsl-vpnkit package already available in "Nix Seach", but does it work? |
Yes, it works. I have been using it for a year. Since it seems to be interest I will prepare a PR. In the meantime all the source code is here. So you could get this today by defining these systemd services. |
I have already implemented this and is wondering if it makes sense to include in this project.
Problem
Some VPN solutions causes problem when used together with WSL, there is wsl-vpnkit to address this issue.
Solution
wsl-vpnkit can be run within NixOS and requires the following:
Packing
wsl-vpnkit
:Creating a systemd service:
The text was updated successfully, but these errors were encountered: