Reconnecting VPN when switching between LAN and Wifi

Hi folks,
I am relatively new to Manjaro and am seeking some help.
I have a couple of use cases and am trying to get the internet connections do act as I would like.
When I am at my office desk I plug in the LAN cable and connect this way. In any other part of the house, the cable is unplugged and I connect to the WiFi, (the router is dual band with options of a typical 2.4GHz and 5GHz)

What I am trying to achieve is that whenever the LAN is plugged in then to 'forget' the WiFi and connect via cable, but as soon as that is unplugged to then to connect to WiFi; 2.4Ghz as the first option and then 5GHz.

At the moment if I plug in the cable it connects but as soon as I pull it out I have to manually select a WiFi and this is annoying. Any advice on how to manage these connections would be great.

Note here that all 3 connections automatically connect to NordVPN
Please let me know of any outputs needed for clarity, as I say I quite new to this.

Best,
M

You don't supply any useful information - so get used to it - you can't expect your computer to think like a human.

You can't just disconnect a LAN and expect the WiFi to take over - especially when the connection is over VPN.

In Network Manager on a connections Global tab you can assign a priority to that connection. You can also make it connect using VPN - but be prepared - it does not always work as you think.

It seems you need to make your network connection remember the password.
Depending on your DE and network manager.
Generally, open network settings, edit your wifi connection and make sure Security has your password saved. Also, there should be settings for "Connect to this automatically with priority" (set a high number, like 40) and "Connect to this VPN automatically".
Basic info:

inxi -SManxxxz

Hi AgentS,
Each of the 3 separate connections are all enabled to connect automatically with the password saved for both the network and VPN. When I need to select the WiFi manually it is only by clicking the 'Connect' button and it then logs in, no need to enter any passwords so I know that they are correct.

I tried your suggestion of increasing the priority number but nothing happens

Here is the output requested

System: Host: thesabear-pc Kernel: 5.3.12-1-MANJARO x86_64 bits: 64 compiler: gcc v: 9.2.0
parameters: BOOT_IMAGE=/boot/vmlinuz-5.3-x86_64 root=UUID=a490d7b8-cdd6-4b1c-8e75-271996e56eaa
rw quiet apparmor=1 security=apparmor resume=UUID=736cd2d9-4165-4b27-8822-e553579a52c2
udev.log_priority=3
Desktop: KDE Plasma 5.17.3 tk: Qt 5.13.2 info: latte-dock wm: kwin_x11 dm: SDDM
Distro: Manjaro Linux
Machine: Type: Laptop System: ASUSTeK product: N501JW v: 1.0 serial:
Mobo: ASUSTeK model: N501JW v: 1.0 serial: UEFI: American Megatrends v: N501JW.211
date: 10/28/2015
Network: Device-1: Intel Wireless 7260 driver: iwlwifi v: kernel port: e000 bus ID: 3b:00.0
chip ID: 8086:08b1
IF: wlp59s0 state: down mac:

Maybe check VPN settings.
I don't have experience with VPN. I don't remember having this issue (I use Plasma too) with standard networking. :man_shrugging:

As for

I wonder how many times a day and in how long/short time you have to change this pressing a button, to be annoying, no disrespect. :smile:

If there is a solution for this, @linux-aarhus has a lot of experience with VPN :point_up_2:

1 Like

Do you use NM to manage your VPN?

Because normally this works without any interaction. However if a VPN is involved, it gets complicated. The main problem is that the VPN is one connection. If you remove the cable, the VPN connection needs to be close and reconnect. Depending on the VPN software, it often fail.

Try it a few times without a VPN. Just to see if it makes a difference.

1 Like

You are right, maybe annoying is the wrong word and kinda strong. It's more that I would prefer for it to function more smoothly and transition between the options when available

Yes, I use NM. I have just tested it with VPN access turned off and the various connections work as I would like them too. Any ideas on a workaround when VPN is enabled?

I can't test it at the moment, but you can try to replace the VPN server hostname with the IP. Also keep the timeout in mind. After you remove the cable you might need to wait some minutes (not seconds) until you have a internet connection. A connection to your LAN should work nearly immediately.
You could also try you use only DNS server in your LAN. A dedicated RPI with a trusted DNS solution might work better as a internet DNS you use thru your VPN.

You also might consider to use a dedicated VPN router.

2 Likes

Probably not.

The boring technicalities makes it impossible for a good VPN to connect when MAC adresses change. Network connections - in their very core depends on MAC addresses.

When you pull you LAN with a VPN connected - and expecting it to reconnect automatically - you are basically expecting your system's VPN to completely transfer trust from one MAC to another.

How can your systems VPN know the connection is trusted? It could be a MITM attack? While you know the connection is trusted - because you know you made the change - the system don't - unless you manually connect and reestablish the VPN connection.

The disconnection - IMO - is expected behavior - and certainly not something to be handled transparently as this would break confidenciality.

I agree with the point made - create the VPN at router level.

(change OP title to reflect the issue - reconnecting VPN when switching between LAN and WiFi)

here is an article in german that describes a way to switch automatically between lan and wifi.


page 2 describes the procedure to create this automatically switching. i'm not that expert and it doesn't interest me, but it seems that there are ways to implement such a procedure.

In modern times, this is done automatically. Also this tutorial is over a decade old. Not to mention, it is written for Debian.

The problem is the third player, a VPN connection. The switch between LAN and Wifi works.

I appreciate all the help and comments. I understand now the reason why it would not connect; everyday is a school day.
In terms of creating the VPN at router level and other suggestions, these are way past my technical capabilities at this point, although I will keep this in mind and look in future to try and implement this.
For now manually connecting will do.

Once again, really appreciate the advice
Best,
M

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by