How to force to Linux to connect only 5GHz channel?

Solution 1:

For any distro with Network Manager, this is an editable parameter in the nm-connection-editor UI. You may wish to change this setting for each saved connection since not all routers are created equal. This feature has existed in Network Manager since 2008 (which appears to correspond to NM Applet >= 0.7.2).

  1. Run nm-connection-editor or open your network settings and edit your WiFi connection. If you're on a distro like Arch, you might want to install this package.
  2. There is a Band option under the Wi-Fi tab that will let you select Automatic, A (5 GHz), or B/G (2.4 GHz). If you don't have the 5 GHz option, you might need to debug further (I can't say definitively from lack of experience with older systems).

Solution 2:

Here is one possible solution, where you do not use network-manager anymore to manage your wireless interface, but you directly use wpa_supplicant. This means in Ubuntu you won't have the convenience anymore to use your GUI to select between networks.

Here is what you need to do:

1
Enter this to your /etc/network/interfaces file (replace wlan0 with the name of your wireless interface):

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

This will cause network-manager not to manage the interface wlan0 anymore.
If you want to revert this behaviour, please simply comment out what you added in this file.

2 Create/edit the file /etc/wpa_supplicant/wpa_supplicant.conf with the following content:

ctrl_interface=/var/run/wpa_supplicant

network={
    ssid="Your_AP"
    psk="Your_Passphrase"
    freq_list=2412 2437 2462
}

The values after freq_list have to be adapted by you. They secify the center frequency of the allowed channels to which you want to connect. In the case of the above example, I have added the channels 1, 6 and 11 of the 2.4 GHz band. The center frequencies for the 5 GHz band can be found e.g. in Wikipedia.