Saturday, May 18, 2024
 Popular · Latest · Hot · Upcoming
23
rated 0 times [  23] [ 0]  / answers: 1 / hits: 7233  / 1 Year ago, sun, april 23, 2023, 4:15:05

I installed Ubuntu 20.04 some days ago. Most things work very fine.


But if I am connected via LAN, I get the warning again and again that WiFi can't connect.


This does not make sense.


If I have LAN, then I don't need WiFi.


Of course I can disable it by hand, but an automation which works be default would be fine.


What can I do to solve this?


More From » networking

 Answers
6

from manpage of Ubuntu for nmcli-examples https://manpages.ubuntu.com/manpages/focal/man7/nmcli-examples.7.html Example 14. there is a script to make Ethernet and Wi-Fi mutually exclusive


#!/bin/bash
export LC_ALL=C

enable_disable_wifi ()
{
result=$(nmcli dev | grep "ethernet" | grep -w "connected")
if [ -n "$result" ]; then
nmcli radio wifi off
else
nmcli radio wifi on
fi
}

if [ "$2" = "up" ]; then
enable_disable_wifi
fi

if [ "$2" = "down" ]; then
enable_disable_wifi
fi


   This dispatcher script makes Wi-Fi mutually exclusive with wired networking. When a wired
interface is connected, Wi-Fi will be set to airplane mode (rfkilled). When the wired
interface is disconnected, Wi-Fi will be turned back on. Name this script e.g.
70-wifi-wired-exclusive.sh and put it into /etc/NetworkManager/dispatcher.d/ directory.
See NetworkManager(8) manual page for more information about NetworkManager dispatcher
scripts.


Make the new script executable: chmod a+rx /etc/NetworkManager/dispatcher.d/70-wifi-wired-exclusive.sh


[#2746] Tuesday, April 25, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
musining

Total Points: 171
Total Questions: 124
Total Answers: 121

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;