8

In the building where I am living is having a WiFi with two channels and same SSID. Whenever I connect to the WiFi, it always connects to the 2.4GHz band but I want to connect to 5GHz band. I have already tried this but all in vain. Also, I have tried linSSID app but it isn't even launching.

I am using Ubuntu 18.04 LTS and output of lshw -C network:

  *-network                 
       description: Wireless interface
       product: Wireless 3160
       vendor: Intel Corporation
       physical id: 0
       bus info: pci@0000:01:00.0
       logical name: wlp1s0
       version: 83
       serial: e4:02:9b:d2:65:c7
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=iwlwifi driverversion=4.15.0-34-generic firmware=17.948900127.0 ip=172.21.126.136 latency=0 link=yes multicast=yes wireless=IEEE 802.11
       resources: irq:128 memory:df100000-df101fff

Output of iwlist chan:

wlp1s0    26 channels in total; available frequencies :
          Channel 01 : 2.412 GHz
          Channel 02 : 2.417 GHz
          Channel 03 : 2.422 GHz
          Channel 04 : 2.427 GHz
          Channel 05 : 2.432 GHz
          Channel 06 : 2.437 GHz
          Channel 07 : 2.442 GHz
          Channel 08 : 2.447 GHz
          Channel 09 : 2.452 GHz
          Channel 10 : 2.457 GHz
          Channel 11 : 2.462 GHz
          Channel 12 : 2.467 GHz
          Channel 13 : 2.472 GHz
          Channel 36 : 5.18 GHz
          Channel 40 : 5.2 GHz
          Channel 44 : 5.22 GHz
          Channel 48 : 5.24 GHz
          Channel 52 : 5.26 GHz
          Channel 56 : 5.28 GHz
          Channel 60 : 5.3 GHz
          Channel 64 : 5.32 GHz
          Channel 149 : 5.745 GHz
          Channel 153 : 5.765 GHz
          Channel 157 : 5.785 GHz
          Channel 161 : 5.805 GHz
          Channel 165 : 5.825 GHz
4
  • I know that it is possible in an UniFi WiFi setup, to set the AP to prefer 5Ghz. Or that in most systems you can set up one SSID for normal and one SSID for 5Ghz. You may check if your WiFi setup has such feature, so it counts for all devices in your network and doesn't rely on device-specific configuration.
    – Paul
    Nov 16 '18 at 10:38
  • Have you confirmed that your computer has 5GHz capability? Not all wifi cards do.
    – Thomas Ward
    Nov 16 '18 at 16:32
  • @ThomasWard Yup it has. Actually I've dual booted system and I can set preference for 5GHz in windows easily. To avoid further confusion I've added output of iwlist chan.
    – Kulfy
    Nov 16 '18 at 19:13
  • @Paul How do I check that?
    – Kulfy
    Nov 16 '18 at 19:14
9
+50

To confirm that your wireless card is capable of connecting to 5ghz do iw list and look for the portion that looks like below

...
   Frequencies:
                * 5180 MHz [36] (22.0 dBm) (no IR)
                * 5200 MHz [40] (22.0 dBm) (no IR)
                * 5220 MHz [44] (22.0 dBm) (no IR)
                * 5240 MHz [48] (22.0 dBm) (no IR)
                * 5260 MHz [52] (20.0 dBm) (no IR, radar detection)
                * 5280 MHz [56] (20.0 dBm) (no IR, radar detection)
                * 5300 MHz [60] (20.0 dBm) (no IR, radar detection)
                * 5320 MHz [64] (20.0 dBm) (no IR, radar detection)
                * 5500 MHz [100] (22.0 dBm) (no IR, radar detection)
                * 5520 MHz [104] (22.0 dBm) (no IR, radar detection)
                * 5540 MHz [108] (22.0 dBm) (no IR, radar detection)
                * 5560 MHz [112] (22.0 dBm) (no IR, radar detection)
                * 5580 MHz [116] (22.0 dBm) (no IR, radar detection)
                * 5600 MHz [120] (22.0 dBm) (no IR, radar detection)
                * 5620 MHz [124] (22.0 dBm) (no IR, radar detection)
                * 5640 MHz [128] (22.0 dBm) (no IR, radar detection)
                * 5660 MHz [132] (22.0 dBm) (no IR, radar detection)
                * 5680 MHz [136] (22.0 dBm) (no IR, radar detection)
                * 5700 MHz [140] (22.0 dBm) (no IR, radar detection)
...

To answer your question, I am assuming the network card is capable of connecting to the 5ghz network. Using the command line interface is flexible compared to using the network manager gui. The important thing is to get the ssid and bssid of the 5ghz network you want to connect to.

sudo systemctl restart wpa_supplicant
sudo wpa_cli -iwlp2s0 scan_results

This would list some values such as

bssid / frequency / signal level / flags / ssid
    54:a2:74:03:c3:a2   2437    -79 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  \x00
    54:a2:74:03:c3:a0   2437    -79 [WPA2-EAP-CCMP][ESS]    SOME WIFI
    00:42:68:15:f0:92   2437    -90 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  \x00
    d8:b1:90:3e:e4:62   2412    -79 [WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]  \x00
    d8:b1:90:3e:e4:6e   5700    -84 [WPA2-EAP-CCMP][ESS]    DESIRED SSID
    54:a2:74:03:c6:a1   2462    -90 [WPA2-EAP-CCMP][ESS]    eduroam
    2a:a3:c4:8d:32:85   2437    -71 [WPA2-PSK-CCMP][WPS][ESS][P2P]  Another SSid
    54:a2:74:03:c6:ae   5500    -89 [WPA2-EAP-CCMP][ESS]    eduroam
    54:a2:74:03:c3:a1   2437    -73 [WPA2-EAP-CCMP][ESS]    eduroam
    00:42:68:15:f0:91   2437    -88 [WPA2-EAP-CCMP][ESS]    eduroam
    d8:b1:90:3e:e4:61   2412    -74 [WPA2-EAP-CCMP][ESS]    eduroam

Look for your desired ssid and the corresponding frequency. Now look for the BSSID that matches the desired frequency and SSID.

Next, kill network-manager and wpa_supplicant:

sudo service network-manager stop && sudo killall wpa_supplicant

This may not be desirable for most people but for the purposes of your question.

Create a wpa_supplicant.conf:

sudo nano /etc/wpa_supplicant.conf

and paste the network specs of the network you are connecting to:

ctrl_interface=/var/run/wpa_supplicant

#settings for an AP using preshared keys, PSK
network={
        ssid="DESIRED SSID"
        scan_ssid=1 
        key_mgmt=WPA-PSK
        psk="PassworD"
        bssid=d8:b1:90:3e:e4:6e   #the important part
}

#settings for an open AP. if you use this then don't use the above settings
network={
        ssid="DESIRED SSID"
        key_mgmt=NONE
        bssid=d8:b1:90:3e:e4:6e
}

Replace bssid with the one of the network you are connecting to

Now start wpa_supplicant via that conf file:

sudo wpa_supplicant -iwlp2s0 -c/etc/wpa_supplicant.conf

After authentication flush any held ip addresses:

sudo dhclient -r

Request a dynamic ip (dhcp):

sudo dhclient wlp2s0

At this point you should be connected to the 5ghz network.

To check whether you are really connected to the 5ghz but not the 2ghz do iw dev and you should have a results like

Interface wlp2s0
    ifindex 2
    wdev 0x1
    addr b4:6d:83:15:9c:5d
    ssid DESIRED SSID
    type managed
    channel 140 (5700 MHz), width: 20 MHz (no HT), center1: 5700 MHz
    txpower 22.00 dBm

The whole procedure above works well but may not survive a reboot and is not useful if you would want to be switching between different kinds of networks.
To start initialize network manage:

sudo service network-manager restart

Then from the network tray icon connect to your DESIRED SSID. Never mind whether it is 2.4 or 5ghz. we would do that later.

Now do:

sudo wpa_cli -iwlp2s0 scan_results

To get the BSSID that matches the desired frequency and ssid

Next click the network manager tray icon > edit connections > double click on the DESIRED SSID to edit it as following

On wifi tab: SSID (DESIRED SSID), mode (Client), band (5), channel (enter the value you got from the scan results), bssid (enter desired bssid) device (wlp1s0), cloned mac (permanent), mtu (automatic)

Then disconnect and connect again and it should work.

2
  • it can be done with network manager also. Let me update the answer to include that. this was just a quick fix
    – ptetteh227
    Nov 18 '18 at 16:35
  • What if I don't want to hard code the MAC address of the 5GHz interface of the AP? I just want my client to prefer the 5GHz band (even if the 2.4GHz band has slightly higher received signal strength), but still connect on the 2.4Ghz band if the 5GHz connection is out of range.
    – user643011
    Dec 27 '20 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.