luxzg / WSL2-fixes

Fix-up scripts for WSL2, mainly networking related
198 stars 23 forks source link

VPN #1

Closed lbonini94 closed 1 year ago

lbonini94 commented 1 year ago

I ran your tutorial and it worked over here. I have a notebook with 2 network cards (wifi and ethernet) and I can change my connection through the hyper-v interface. it turned out really good.

I'm facing just one problem: I have a .ovpn file that I use to connect over a VPN. I installed the necessary packages looking at wsl2 as a virtual machine, however network-manager (nmcli) does not behave as expected;

sudo nmcli device status returns all as unmanaged. Could you explain to me why this happens or suggest a solution?

luxzg commented 1 year ago

Thanks for feedback! I only have one VPN to test, and it's not openVPN, I'll need to check, setup openVPN endpoint somewhere else, or something. I'll keep you updated, I'm interested as well.

luxzg commented 1 year ago

Did you try using OpenVPN client instead, without Network Manager?

As I now read into it, maybe you don't use Network Manager at all.

Because if you followed my guide, then you don't have Network Manager doing anything, instead interfaces are managed by other services. You may try doing what's explained in this post: https://askubuntu.com/a/71205/1080682

So potential solutions are: A) use OpenVPN without Network Manager (nmcli included) B) enable Network Manager and manage all interfaces with it (both VPN and your bridged connection)

I am too old and used to the world without Network Manager, so I keep having it disabled. Well, in WSL it's not installed by default anyway.

luxzg commented 1 year ago

OK, so I've decided to get NetworkManager working.

Used resources: https://askubuntu.com/questions/1371275/where-has-the-network-manager-service-in-21-10-gone https://askubuntu.com/questions/71159/network-manager-says-device-not-managed

I did all with root so:

sudo su

I tried nmcli first and as expected got reply:

Command 'nmcli' not found, but can be installed with:
snap install network-manager  # version 1.2.2-29, or
apt  install network-manager  # version 1.36.6-0ubuntu2
See 'snap info network-manager' for additional versions.

Then I've installed it with apt (not snap):

apt install network-manager

Now, I had some issues due to service naming. New networking service is no longer network-manager but NetworkManager and it is case sensitive (!!) which my brain didn't comprehend in time...

I've next enabled management in config:

nano /etc/NetworkManager/NetworkManager.conf

setting it to managed=true

But nmcli device status still showed unmanaged.

I tried nmcli networking off and nmcli networking on, checking log with journalctl -b 0 -u NetworkManager , nmcli connection show and starting (wrong named) services. I even did create file:

cd /etc/NetworkManager/conf.d/
touch 10-globally-managed-devices.conf

Now it's hard to say which one helped, but when I finally found service was case sensitive it started working:

systemctl enable NetworkManager
service NetworkManager restart

nmcli device status

DEVICE  TYPE      STATE                   CONNECTION
eth0    ethernet  connected (externally)  eth0

nmcli connection show

NAME                UUID                                  TYPE      DEVICE
eth0                3e8c7b47-cbba-4289-af69-e50eb0fe1716  ethernet  eth0
Wired connection 1  553ea729-8455-345d-8612-5654c1eda925  ethernet  --

So, just to make sure, I've uninstalled package and deleted files I've created.

    apt remove network-manager
    rm /etc/NetworkManager/conf.d/10-globally-managed-devices.conf

Seems it is enough to apt install network-manager + managed=true in NetworkManager.conf + create file 10-globally-managed-devices.conf + enable and restart service (with correct case sensitive naming).

After doing that, try importing and enabling your OpenVPN connection. Please let me know how it went!

lbonini94 commented 1 year ago

Did you try using OpenVPN client instead, without Network Manager?

As I now read into it, maybe you don't use Network Manager at all.

Because if you followed my guide, then you don't have Network Manager doing anything, instead interfaces are managed by other services. You may try doing what's explained in this post: https://askubuntu.com/a/71205/1080682

So potential solutions are: A) use OpenVPN without Network Manager (nmcli included) B) enable Network Manager and manage all interfaces with it (both VPN and your bridged connection)

I am too old and used to the world without Network Manager, so I keep having it disabled. Well, in WSL it's not installed by default anyway.

I installed the openvpn gui for windows and I didn't even remember to search for a client for linux. Using the openvpn3 client it worked, I ended up not even trying to configure the network-manager. thank you very much for your kind support