62

Currently I'm in a new building of my university. In this building my wifi often breaks down and then restores connection again. This is really irritating since it happens a lot.

Now as a coincidence there were some tech guys running around here and where asking everyone if the wifi was doing fine. I told them that my wifi tears down all the time and then reconnects. They figured out that my wifi is switching all the time between the 2.4 GHz channel and 5 GHz channel. They asked me if I could acces the driver settings of my wireless card. Unfortunately I don't know how to do this is in either Linux or Windows. And unfortunately again they only knew the windows solution xD.

So I hope somebody can tell me how I tell my wifi that it should stay on the 5 GHz network and not disconnect and switch to the 2.4 GHz channel?

-edit-

@arhimed, firstly thank you for your help.

I just tried what you said. It is some what different for me. I can't seem to save the settings when I change the setting and choose to use only the 5 GHz band.

"Network connections"->"Select the appropriate wireless network and click edit"->"In the wireless tab"->"Change the mode from infrastructure to ad-hoc"->"Choose 5 GHz band"

Wireless connection settings panel

However when I want to change the mode from infrastructure to ad-hoc the "save" button tells me that I have to authenticate myself. However I get no pop-up asking me for a password. Using sudo gnome-control-center didn't help either. I could still not save it. Also a error occured then in the terminal:

** (nm-connection-editor:5577): WARNING **: Invalid setting Wireless Security: Security not compatible with Ad-Hoc mode

Hopefully this is some useful info for you to help me further.

BenMorel
  • 161
WG-
  • 1,780
  • 1
    If possible, please consider closing some of your other open questions by selecting the best answer (if they have one). Consider which answers have been useful and need an upvote. We need users to maintain their questions so that the site can be an effective tool for the next person with your problems. For more details on best practices consider reading the FAQ on asking questions. – fossfreedom Sep 03 '12 at 09:43
  • 1
    I haven't tried but I hope that will help you. So, go to network-manager-> edit connections, wireless connections->select you network->Change... Set 'Mode' to 'Special' and frequency to 5GHz. – Viktor K Sep 03 '12 at 10:12
  • @arhimed I replied to you in my main post. Hopefully you can help me further with this new info. – WG- Sep 03 '12 at 12:42
  • Yeah, that won't help you. Have you tried to connect to your network through terminal? – Viktor K Sep 03 '12 at 17:59
  • No because I don't know how to do that. All the info I find about it I find hard to understand. – WG- Sep 04 '12 at 08:03
  • there may be some information here! http://portforward.com/ – Alvar Sep 07 '12 at 14:48
  • That is a website about how to forward a port on different types of routers for games and such, and basic wifi setup. Not something that could help me with fixing my wifi connection, i.e. changing the setting to prefer 5 GHz to 2.4 GHz. – WG- Sep 07 '12 at 14:56
  • The answers here are a bit outdated, in Ubuntu 20 it's simple: run nm-connection-editor, click your wifi, and in 'mode' choose 2.4Ghz. – Plumpie Jul 24 '20 at 08:04
  • Related: https://askubuntu.com/questions/202288/how-do-i-require-use-of-the-5-ghz-band-when-connecting-to-a-wireless-n-access-po – Gabriel Staples Sep 01 '20 at 06:01
  • Also related: https://bbs.archlinux.org/viewtopic.php?id=250872. Contains the seemingly-useful command nm-connection-editor to open up a GUI configuration tool (that appears to be NOT the default on Ubuntu 20.04). – Gabriel Staples Sep 01 '20 at 07:25

5 Answers5

40

Run:

$ iwlist wlan0 scanning | grep -C3 <name of your network>

You should find 2 entries for the network, for example:

Cell XX - Address: 11:11:11:11:11:11 // This will be different in your machine
ESSID: "name of your network" // This will be different on your machine
Protocol: IEEE 802.11bgn
Mode: Master
Frequency: 2.437 Ghz

--

Cell XX - Address: 22:22:22:22:22:22 // This will be different on your machine
ESSID: "name of your network // This will be different on your machine
Protocol: IEEE 802.11AC
Mode: Master
Frequency: 5.18 Ghz
  • BSSID for the 5Ghz Network, in this example: 22:22:22:22:22:22
  • BSSID for the 2.4 Ghz Network, in this example: 11:11:11:11:11:11

Now what you do is:

  1. click on 'Network Connections'
  2. 'Edit Connections...'
  3. [Select your network connection] (there could be 2 entries, any will do)
  4. Click Edit
  5. Go to 'Wi-Fi' or 'Wireless' Tab
  6. Click the BSSID Dropdown
  7. Select the BSSID Matching the 5 Ghz Network (22:22:22:22:22:22 in this example)
  8. Switch to the 'General Tab'
  9. Make sure to check the checkbox that is labeled: 'Automatically connect to this network when it is available'
  10. Rename the Connection Name (not the SSID) to 'your network name'_AC
  11. Click Save
  12. If there were 2 entries for 'your network name' in your Network Connections list, proceed with next step, otherwise go to the last step.
  13. Click on the other 'your network name' entry
  14. Click Edit
  15. Go to 'Wi-Fi' or 'Wireless' Tab
  16. Click the BSSID Dropdown
  17. Select the BSSID Matching the 2.4 Ghz Network (11:11:11:11:11:11 in this example) OR leave the BSSID empty if there are multiple other secondary access points
  18. Switch to the 'General' Tab
  19. Uncheck the checkbox that is labeled: 'Automatically connect to this network when it is available'
  20. Set the 'Connection name' to [your network name]_N
  21. Click Save...
  22. Disconnect from your network and re-connect

You should now be connected to the 5Ghz network, and you would have to explicitly do the opposite process in order to connect to the 2.4 Ghz Network.

EoghanM
  • 5,125
  • ty this was super helpful! works on ubuntu 20.04 as well – Mike Chelen Jun 19 '20 at 15:09
  • 4
    -C3 wasn't enough context lines. I had to do -C5 or higher to obtain the line containing the Cell xx line with the BSSID in it. Ex: iwlist wlan0 scanning | grep -C5 my_network_name. – Gabriel Staples Sep 01 '20 at 05:49
  • 2
    Thx for so detailed answer. Just wanted to note that your network interface may be named differently. In my case it is not wlan0, but wlx0013eff40041. To get the real name you can use iwconfig – faiwer Apr 23 '21 at 11:56
  • Where is "Network Connections"? – tparker Apr 11 '22 at 14:45
  • @tparker - if you have a Wifi icon in the top bar (for me it is to the right), click on it, and you will get a submenu with a partial list of "Wi-Fi Networks", and some commands below - from the commands, click on "Edit Connections...", and you will get a Network Connections window. Or just nm-connection-editor from the Terminal. Also, on my Ubuntu 22, BSSID is not reported by iwlist - but there is a dropdown with BSS in Network Connection entries – sdbbs Jun 21 '23 at 21:50
  • what if "Interface doesn't support scanning."? – Line Aug 15 '23 at 09:51
29

Method 1 — for use at home with a single wireless router

First, connect to your basic wifi network under "Infrastructure". Next, click on BSSID. The BSSID you are connected to at that time should appear when you click on that arrow. This feature prevents your computer from switching networks. 2.4 Ghz and 5 Ghz.


Method 2 — roaming on a network with multiple access points like a college campus or public wifi

NOTE: If you used the method above, you will need to do the opposite before you begin. Make sure the BSSID is not set to anything (is blank) so that you can use multiple access-points and roam across the network.

First, you will need to edit the system-connections file that corresponds to your network. For this example, I will use a network named "coffee-shop".

sudo nano /etc/NetworkManager/system-connections/coffee-shop

Now, under the [wifi] section, edit the band field to the following (if band= is not listed, you can insert it on the line below [wifi]):

band=a

This will set the network to use 5 GHz only. If you want to use 2.4 GHz, use band=bg instead.

When you are done editing, press CTRL+o and then press ENTER to save the file and then press CTRL+x to exit nano.

Finally, restart network-manager to apply the changes:

sudo systemctl restart network-manager

Click here for more information.

NOTE: this setting does not exclude you from using wireless n or wireless c (so don't worry), this feature is only used to select 2.4 or 5 GHz

mchid
  • 43,546
  • 8
  • 97
  • 150
  • This won't work if both the 2.4 Ghz and 5 Ghz network connections have the 'Connect automatically when this network is available' checkbox ticked, which is the crux of the problem. – Marcel Valdez Orozco Jun 03 '15 at 12:38
  • 1
    @MarcelValdezOrozco I believe the solution to that problem would be to untic the box of the 2.4 network. – mchid Jun 04 '15 at 00:20
  • Yes, it would be. – Marcel Valdez Orozco Jun 04 '15 at 02:14
  • This doesn't really work when your company/school has 100+ access points across multiple buildings and floors... – Nathan J.B. Oct 12 '15 at 20:52
  • @mchid, not sure where you got that idea. If I limit my wireless connection to ONE mac address, when I go to a different building or different floor (where that ONE mac address isn't available), I won't be able to connect until I update my network settings to accept a different mac address (which I will have to update again when I go back to my desk). And I haven't even mentioned how to find which mac IDs are 5ghz vs 2.4ghz (that dropdown lists 100s of mac IDs, not just the two you mention). – Nathan J.B. Oct 14 '15 at 00:16
  • @NathanJ.Brauer it depends on which version of network-manager you are using. On 14.04, you can easily use the nm-tool command to list the local BSSIDs, their strength and their frequency. Based upon the strength, it's quite easy to see which one you should choose. Use grep to narrow the output to only relevant results like: nm-tool | egrep 'Freq 5.......' If you are using 15.04 you can download the old network manager from here: http://security.ubuntu.com/ubuntu/pool/main/n/network-manager/network-manager_0.9.8.8-0ubuntu7.1_amd64.deb extract the deb and nm-tool is under usr/bin/nm-tool – mchid Oct 14 '15 at 15:08
  • @NathanJ.Brauer just to be clear, do not install the old version of network-manager just download it, extract nm-tool from it, and discard the rest. – mchid Oct 14 '15 at 15:11
  • @NathanJ.Brauer also, just to be clear, set a new separate profile for each ap that you use instead of constantly updating the existing one and make sure to use the "automatically connect to this network" option. This way, you can roam more freely. And it should go without saying that you need to delete any an all existing 2.4Ghz profiles. – mchid Oct 14 '15 at 15:26
  • Yikes. Seems it would be easier if we could just disable 2.4GHz globally. – Nathan J.B. Oct 15 '15 at 21:11
  • @NathanJ.Brauer Android is the only OS that I heard of that has this capability out the box it's seems it's a source of frustration for even the other mainstream operating systems as well: http://superuser.com/questions/362366/does-it-make-sense-to-keep-different-ssids-for-2-4ghz-and-5ghz-wireless-networks and it seems the solution for windows is pretty much the same as described here delete any existing profile for all 2.4Ghz networks and set the 5Ghz networks to automatically connect: http://www.tomshardware.com/answers/id-2156077/forcing-5ghz-band-windows.html – mchid Oct 15 '15 at 23:44
  • 2
    Worked for me (as in force it to use 5ghz via BSSID method). I thought Linux wifi driver would have transparent support for using dual band concurrently, but I guess not. – kchoi Mar 09 '16 at 07:52
  • 2
    Also works to force 2.4Ghz, which gave me dramatically better range. – Jesse Glick Jun 15 '16 at 13:22
  • 1
    F@JesseGlick Yes, lower frequencies travel through solid objects more easily so range is much better on 2.4, however, nearly every radio interference that exists is somewhere near the 2.4 frequency so 5Ghz has the advantage of a less crowded and much less noisy airspace or whatever that is :) – mchid Jul 29 '17 at 04:46
  • thanks this worked for me on ubuntu 20.04 as well! – Mike Chelen Jun 19 '20 at 15:10
  • @NathanJ.B. I finally found a way to do that. See the appended instructions above. – mchid Jan 17 '21 at 15:16
  • 2
    If, like me, you don't trust yourself to edit configuration files by hand, you can also achieve this using official NetworkManager tools via nmcli connection modify <connection name> wifi.band a. – Daniel Wagner Jan 18 '24 at 20:28
6

Change that "Ad-hoc" option to something else, like "Infrastructure" (or a similar menu option). Infrastructure wireless is your typical "lots of devices connecting to a single router" approach, while ad-hoc wireless is intended for a "mesh" of wireless devices with no centralized router.

Being in ad-hoc mode is likely what's causing your problem (and this is further evidenced by the error message you provided).

  • 1
    Thank you for your reply. Further I am not in Ad-hoc. The option stands on Infrastructure. In infrastructure mode the wifi changes from band all the time, 2.4 GHz <-> 5 GHz. I want to try to put my settings in Ad-hoc because in that mode I can select which band I want to use. I can't select a band when in Infrastructure mode. – WG- Sep 14 '12 at 20:03
  • 2
    Alrighty then...

    The problem with ad-hoc mode is that it's not compatible with WPA and WPA2 security protocols (hence the error you got). Normally, the channel/frequency is set by the router.

    You can use iwconfig to set the channel manually. In a terminal, try the following:

    iwconfig eth0 freq 5G

    – YellowApple Sep 14 '12 at 23:04
  • Thank you very much. I will try this monday when I'm on the university. It is indeed possible on the router, but this problem occurs only on the routers when I'm in a certain building at my university. And the IT guys there are not going to configure all the routers just for me ;) – WG- Sep 15 '12 at 10:49
  • Hmmm wel I still get disconnected sometimes but I have the feeling that it is a lot less then it used to be. – WG- Sep 18 '12 at 08:35
  • 2
    I should probably correct my own comment... eth0 normally points to your wired internet connection, so try iwconfig wlan0 freq 5G instead. Sorry about that. – YellowApple Sep 18 '12 at 15:51
  • Yes you are totally correct. I should also have mentioned that I indeed already changed it to the correct name ;-). – WG- Sep 18 '12 at 21:59
  • 2019 called: iwconfig wlan0 freq 5 – Ufos Feb 26 '19 at 10:43
3

This may work or may not work. Based on my experience, it is inconsistent. On the network manager settings, you can manually enter the BSSID of the AP. You can found out the BSSID using an android application called 'WIFI analyzer'. You can also use other linux based wifi monitoring tools like Kismet, but the easiest way that I found out is using the android application. If you don't know, 5Ghz AP have higher channel number (more than 13). Now, the inconsistency, depending on distro, the BSSID select box may be populated, or you have to input it manually. Either way, enter the BSSID that you wish to connect, and set the name of the network to something you can remember, like "U-WIFI-5Ghz". Now unfortunately, sometimes the network will appear (and you can connect to that specific AP) and sometimes it do not even if you know the AP is close by.

asdacap
  • 203
  • 1
    you can also find out by simply using one of the following commands: nm-tool or iwlist scan | grep -B 4 "Frequency:5" | grep "Address:" you could also use iwlist scan | grep -B 4 "Frequency:5" you could narrow the results of the first one: nm-tool | egrep 'Freq 5.......' you can even set up an alias for any one of these in your bashrc file to call on any one of these using a single command. – mchid Oct 14 '15 at 14:57
  • iwlist scan | grep -B 4 "Frequency:5" then finding my BSSID in wifi->my connection-> edit->identity->BSSID worked. – jason m Apr 30 '20 at 19:40
0

Run the following commands, one line at a time in the terminal (CTRL+ALT+T):

echo "options iwlwifi 11n_disable=1" | sudo tee /etc/modprobe.d/iwlwifi.conf
sudo modprobe -rfv iwldvm
sudo modprobe -rfv iwlwifi
sudo modprobe -v iwlwifi

What does this do? The 11n_disable option disables 802.11n features. Adding it to

/etc/modprobe.d/iwlwifi.conf

makes the change persist after reboots (because it will be part of the module config). The modprobe -rfv commands are removing the kernel modules iwldvm and iwlwifi, and finally the last line modprobe -v is adding iwlwifi back in.

To know what those kernel modules are/do, you can run modinfo | grep description, which will tell you the following:

iwlwifi is an Intel(R) Wireless WiFi driver for Linux (generic Intel drivers)

iwldvm is Intel(R) Wireless WiFi Link AGN driver for Linux (more specific drivers)

Other suggestions

Now, check the settings in the router. WPA2-AES is preferred; not any WPA and WPA2 mixed mode and certainly not TKIP. Second, if your router is capable of N speeds, You may have better luck with a channel width of 20 MHz in the 2.4 GHz band instead of automatic 20/40 MHz. I also have better luck with a fixed channel, either 1, 6 or 11, rather than automatic channel selection. After making these changes, you may need to reboot the router.