EnismanY / linux_wifi.md
This provides details including, frequency of WiFi, BSSID, SSID, encryption (for WPA2-PSK, should see pairwise_cipher and group_cipher are CCMP ) MAC address and IP address.
There are several options for turning off WiFi, what works will be dependent on how the system is configured. Assuming the WiFi interface is wlan0 , options are:
sudo ip link set wlan0 down
- First list all devices using:
0: phy0: Wireless LAN Soft blocked: no Hard blocked: no 1: hci0: Bluetooth Soft blocked: no Hard blocked: no
Again, there are multiple options:
sudo ip link set wlan0 up
Alternatively, assuming the number of the device has been ascertained using rfkill list ( 0 in the example below) execute:
Display information about the WiFi interface
Assuming WiFi interface is wlan0 :
Finding WiFi link quality & signal level
iwconfig wlan0 | grep -i --color "Quality\|Signal"
The numbers reported for quality will be WiFi driver dependent.
Continous update of link quality
The file /proc/net/wireless contains information about the WiFi signal. This can be viewed continually using a combination of the cat and watch commands.
watch -n 1 cat /proc/net/wireless
Alternatively, the ncurses-based monitoring application wavemon can be used. This will likely need installing, which in Debian based distributions can be achieved using:
To use the application simply run:
Setting a prefered WiFi band
It is possible to set a preferred WiFi band, ie 2.5 or 5 GHz. This may be desirable to avoid interference from other devices or to improve range/speed. Remember, 2.5 GHz has the better range and 5 GHz the better speed.
First check the network interface is capable of using both bands. There are at least two methods to determine this.
sudo iwlist wlan0 scan | grep -i "Frequency\|Address\|ESSID"
THe output will be similar to:
Cell 01 - Address: ab:12:cd:34:ef:56 Frequency:2.412 GHz ESSID:"DESIRED SSID" Cell 02 - Address: gh:78:ij:90:kl:12 Frequency:5.70 GHz ESSID:"DESIRED SSID" .
iw list | grep -i "Frequencies\|MHz\|GHz"
In the output look for the section(s) entitles Frequencies, which will be similar to:
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) .
The frequencies are the centre of the band.
Both the SSID and BSSID are required, the BSSID is the MAC address for a particular band of the access point. To obtain this information, enter the wpa command line interface by running the following, where wlan0 is the name of the wireless network interface:
Once in the iteractive mode, indicated by:
run the following two commands, letting the first command complete execution (indicated by a return of the > prompt) before running the second.
The output will be similar to:
bssid / frequency / signal level / flags / ssid ab:12:cd:34:ef:56 2412 -79 [WPA2-PSK-CCMP][WPA2-PSK-CCMP][ESS] DESIRED SSID gh:78:ij:90:kl:12 5700 -84 [WPA2-PSK-CCMP][WPA2-PSK-CCMP][ESS] DESIRED SSID .
This shows the desired SSID and the frequencies, 2.5 and 5 GHz, along with their respective BSSIDs.
Quit the interactive mode by entering q .
To modify the settings
Kill network-manager and wpa_supplicant:
sudo service network-manager stop && sudo killall wpa_supplicant
On the Raspberry Pi (August 2020) networking this can be achieved using:
sudo service networking stop && sudo killall wpa_supplicant
If /etc/wpa_supplicant.conf does not exist, create the file using:
sudo wpa_passphrase > /etc/wpa_supplicant
must be replaced with the SSID of the WiFi network. A blank prompt will be received awaiting the user to enter the password for the WiFi. Once this has been done edit the file using:
sudo nano /etc/wpa_supplicant.conf
Add the following to the file.
ctrl_interface=/var/run/wpa_supplicant #settings for an AP using preshared keys, PSK network= < ssid=ssid scan_ssid=1 key_mgmt=WPA-PSK #psk==Password psk="Passkey generated by wpa_passphrase" bssid=gh:78:ij:90:kl:12 #the important part >#settings for an open AP. if you use this then don't use the above settings network=
ssid and psk will be those entered when using the wpa_passphrase command.
Delete the commented line containing the password, and ensure the bssid matches that of the access point and the desired band you wish to connect to, ie 2.5 or 5 GHz.
Now start the daemon in the background by running:
sudo wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0
If this fails, debug problems by running:
sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -d
Unsure about the dhclient section (next two commands)
After authentication, tell dhclient to release the current lease ie IP address, it has from the server:
Request a dynamic IPv4 address (DHCP):
Finally, reconfigure the interface with:
wpa_cli -i wlan0 reconfigure
Verify whether WiFi has successfully connected and the correct band is being used by executing:
sudo wpa_cli -i wlan0 status
If the ip_address is not populated, the device has not connected to the network, check that thr password and ESSID are correct.
Изменение частотного канала WiFi
Я пытаюсь изменить канал wifi на тот, который будет использовать частоту 5 ГГц.
iwconfig lo no wireless extensions. wlo1 IEEE 802.11abg ESSID:off/any Mode:Managed Frequency:5.2 GHz Access Point: Not-Associated Retry short limit:7 RTS thr:off Fragment thr:off Power Management:on eno1 no wireless extensions.
Как только я подключился к своему Wi-Fi, частота переключается на 2,4 ГГц
lo no wireless extensions. wlo1 IEEE 802.11abg ESSID:»PiotryStephy» Mode:Managed Frequency:2.412 GHz Access Point: C0:05:C2:BF:6F:79 Retry short limit:7 RTS thr:off Fragment thr:off Power Management:on eno1 no wireless extensions.
] В настройках моего маршрутизатора допустимы частоты 2 и 5 ГГц.
iwlist channel lo no frequency information. wlo1 29 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 38 : 5.19 GHz Channel 40 : 5.2 GHz Channel 42 : 5.21 GHz Channel 44 : 5.22 GHz Channel 46 : 5.23 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 Current Frequency:2.412 GHz (Channel 1) eno1 no frequency information.
Когда я пытаюсь изменить канал:
sudo iwconfig wlo1 channel 40 Error for wireless request «Set Frequency» (8B04) : SET failed on device wlo1 ; Operation not supported. ]
Set Country Region to enable Wi-Fi channels 12 and 13
First of, we are not using a standard linux, we are using an embedded linux from NXP. The problem that we have is that we are not able to set the country region to enable channels 12 and 13. We have installed CRDA and we are using a Wi-Fi chipset from Cypress (broadcom) The problem: When the Linux boots, we don’t have the wlan0 up, so ifconfig shows this:
13:52:15 root@i:~> ifconfig lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1%1995577040/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:256 errors:0 dropped:0 overruns:0 frame:0 TX packets:256 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:18944 (18.5 KiB) TX bytes:18944 (18.5 KiB) 13:58:41 root@i:~> iw dev phy#0 Interface wlan0 ifindex 4 wdev 0x1 addr 00:90:4c:11:22:33 type managed
iw reg set JP 13:54:15 root@i:~> cfg80211: Regulatory domain changed to country: JP cfg80211: DFS Master region: JP cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), ( dfs_cac_time) cfg80211: (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A) cfg80211: (2474000 KHz - 2494000 KHz @ 20000 KHz), (N/A, 2000 mBm), (N/A) cfg80211: (4910000 KHz - 4990000 KHz @ 40000 KHz), (N/A, 2300 mBm), (N/A) cfg80211: (5030000 KHz - 5090000 KHz @ 40000 KHz), (N/A, 2300 mBm), (N/A) cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A) cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s) cfg80211: (5490000 KHz - 5710000 KHz @ 160000 KHz), (N/A, 2300 mBm), (0 s)
13:58:27 root@i:~> iw list |grep MHz * 2412 MHz [1] (20.0 dBm) * 2417 MHz [2] (20.0 dBm) * 2422 MHz [3] (20.0 dBm) * 2427 MHz [4] (20.0 dBm) * 2432 MHz [5] (20.0 dBm) * 2437 MHz [6] (20.0 dBm) * 2442 MHz [7] (20.0 dBm) * 2447 MHz [8] (20.0 dBm) * 2452 MHz [9] (20.0 dBm) * 2457 MHz [10] (20.0 dBm) * 2462 MHz [11] (20.0 dBm) * 2467 MHz [12] (20.0 dBm) * 2472 MHz [13] (20.0 dBm) * 2484 MHz [14] (20.0 dBm)
The problem is: When we bring up the wlan0, using ifup wlan0 or ip lik set wlan0 up, the iw reset the channels 11 and 12:
14:01:53 root@i:~> iw list |grep MHz * 2412 MHz [1] (20.0 dBm) * 2417 MHz [2] (20.0 dBm) * 2422 MHz [3] (20.0 dBm) * 2427 MHz [4] (20.0 dBm) * 2432 MHz [5] (20.0 dBm) * 2437 MHz [6] (20.0 dBm) * 2442 MHz [7] (20.0 dBm) * 2447 MHz [8] (20.0 dBm) * 2452 MHz [9] (20.0 dBm) * 2457 MHz [10] (20.0 dBm) * 2462 MHz [11] (20.0 dBm)
Broadcom uses the command tool «wl». We only can use this tool, once wlan0 is up. If we check the channels available, we can see that channels 11 and 12 are not available:
14:02:03 root@i:~> wl chan_info Channel 1 B Band Channel 2 B Band Channel 3 B Band Channel 4 B Band Channel 5 B Band Channel 6 B Band Channel 7 B Band Channel 8 B Band Channel 9 B Band Channel 10 B Band Channel 11 B Band
14:03:32 root@i:~> wl country GB 14:04:25 root@i:~> wl chan_info Channel 1 B Band Channel 2 B Band Channel 3 B Band Channel 4 B Band Channel 5 B Band Channel 6 B Band Channel 7 B Band Channel 8 B Band Channel 9 B Band Channel 10 B Band Channel 11 B Band Channel 12 B Band Channel 13 B Band
14:01:53 root@i:~> iw list |grep MHz * 2412 MHz [1] (20.0 dBm) * 2417 MHz [2] (20.0 dBm) * 2422 MHz [3] (20.0 dBm) * 2427 MHz [4] (20.0 dBm) * 2432 MHz [5] (20.0 dBm) * 2437 MHz [6] (20.0 dBm) * 2442 MHz [7] (20.0 dBm) * 2447 MHz [8] (20.0 dBm) * 2452 MHz [9] (20.0 dBm) * 2457 MHz [10] (20.0 dBm) * 2462 MHz [11] (20.0 dBm)
14:07:55 root@i:~> iw reg set GB 14:08:01 root@i:~> cfg80211: Regulatory domain changed to country: GB cfg80211: DFS Master region: ETSI cfg80211: (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time) cfg80211: (2402000 KHz - 2482000 KHz @ 40000 KHz), (N/A, 2000 mBm), (N/A) cfg80211: (5170000 KHz - 5250000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (N/A) cfg80211: (5250000 KHz - 5330000 KHz @ 80000 KHz, 160000 KHz AUTO), (N/A, 2000 mBm), (0 s) cfg80211: (5490000 KHz - 5710000 KHz @ 160000 KHz), (N/A, 2700 mBm), (0 s) cfg80211: (57000000 KHz - 66000000 KHz @ 2160000 KHz), (N/A, 4000 mBm), (N/A) 14:01:53 root@i:~> iw list |grep MHz * 2412 MHz [1] (20.0 dBm) * 2417 MHz [2] (20.0 dBm) * 2422 MHz [3] (20.0 dBm) * 2427 MHz [4] (20.0 dBm) * 2432 MHz [5] (20.0 dBm) * 2437 MHz [6] (20.0 dBm) * 2442 MHz [7] (20.0 dBm) * 2447 MHz [8] (20.0 dBm) * 2452 MHz [9] (20.0 dBm) * 2457 MHz [10] (20.0 dBm) * 2462 MHz [11] (20.0 dBm)
13:59:45 root@i:~> ifup wlan0 Successfully initialized wpa_supplicant rfkill: Cannot open RFKILL control device Dongle Host Driver, version 1.141.92 (r) Compiled in drivers/net/wireless/bcmdhd wl_android_wifi_on in mmc0: queuing unknown CIS tuple 0x80 (2 bytes) mmc0: queuing unknown CIS tuple 0x80 (3 bytes) mmc0: queuing unknown CIS tuple 0x80 (3 bytes) mmc0: queuing unknown CIS tuple 0x80 (7 bytes) mmc0: queuing unknown CIS tuple 0x80 (3 bytes) mmc0: queuing unknown CIS tuple 0x80 (6 bytes) F1 signature OK, socitype:0x1 chip:0xa9a6 rev:0x1 pkg:0x3 DHD: dongle ram size is set to 524288(orig 524288) at 0x0 dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded. dhd_bus_init: enable 0x06, ready 0x06 (waited 0us) wifi_platform_get_mac_addr Firmware up: op_mode=0x0005, MAC=60:f1:89:cb:cb:17 Firmware version = wl0: Dec 11 2014 04:20:45 version 7.10.323.34 (r520360) FWID 01-ea2beeba dhd_wlfc_init(): successfully enabled bdcv2 tlv signaling, 79 dhd_wlfc_init: query wlfc_mode succeed, fw_caps=0x1c dhd_wlfc_init(): wlfc_mode=0x1c, ret=0 CFG80211-ERROR) wl_update_wiphybands : error reading vhtmode (-23) wl_create_event_handler(): thread:wl_event_handler:246 started CFG80211-ERROR) wl_event_handler : tsk Enter, tsk = 0x8a46143c
2-Maybe the problem is that I have to execute the wl tool before bring up the wlan0 interface, but wl command cannot find the interface if it is not up. Thanks for your time.