Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Have Network Manager prefer one wireless card over another
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
evlich
Tux's lil' helper
Tux's lil' helper


Joined: 17 Oct 2007
Posts: 107

PostPosted: Tue Feb 18, 2014 2:08 pm    Post subject: Have Network Manager prefer one wireless card over another Reply with quote

Hello --

I have two wireless cards installed in my laptop, the second works much better than the first, unfortunately the first is the internal one. When I start up, they both find a network and NetworkManager opts to use the first where I would like it to use the second. Is there a way to tell NetworkManager to connect using the second wireless card if it is present? I don't want to completely disable the internal wireless because sometimes I find myself without the second card and I need to use it.

Thanks.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Tue Feb 18, 2014 2:17 pm    Post subject: Reply with quote

If you can't find a way to do that in NM then you can switch to a pure dhcpcd based setup where you can do it

Code:

interface wlan0
metric 500

# Prefer wlan1 with a lower metric
interface wlan1
metric 400

_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1636
Location: United Kingdom

PostPosted: Tue Feb 18, 2014 3:45 pm    Post subject: Reply with quote

I don't know if NetworkManager allows you to specify a preferred WiFi device if you have two. However, although I'm no expert I imagine you could use NetworkManagerDispatcher as a sort of work-around to achieve what you want. You could create a script in /etc/NetworkManager/dispatcher.d/ to be run by NetworkManagerDispatcher when a network connection is established. The script could check if both devices are present and if the connection is via the preferred (external) WiFi device. If both devices are present and the connection is via the non-preferred (internal) WiFi device, the script could disconnect from the network and reconnect via the preferred device instead. I would try using the nmcli command (it is installed with NetworkManager) to do the checking, disconnection and reconnection, as you can specify devices by id or uuid.

I'm thinking of a script /etc/NetworkManager/dispatcher.d/00_preferred-wifi-device along the following lines:

Code:
#!/bin/bash
 
INTERFACE=$1 # The interface which is brought up or down
STATUS=$2 # The new state of the interface
 
case "$STATUS" in
    'up') # $INTERFACE is up
        # Add code here...
        # Use nmcli to check which of the WiFi devices are available and which is currently in use.
        # If both devices are available and connection is via the internal device, then:
        #    Disconnect from the network.
        #    Connect using the preferred WiFi device.
        # Endif
        ;;
    'down') # $INTERFACE is down
        # Do not need to do anything, as WiFi is not being used.
        ;;
esac

Not having the hardware to try it myself, I'm not sure it would work, but it looks like a possible approach.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum