NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.3k stars 13.54k forks source link

Creating a wifi hotspot doesn't work #67956

Open cxandru opened 5 years ago

cxandru commented 5 years ago

Issue description

Creating a secured wifi hotspot (i.e. following the instructions here:https://unix.stackexchange.com/questions/234552/create-wireless-access-point-and-share-internet-connection-with-nmcli) Doesn't work: The attempt to bring the connection up fails with 'Error: Connection activation failed: 802.1X supplicant took too long to authenticate'.

This seems to me related to this bug: https://bugzilla.redhat.com/show_bug.cgi?id=1518190 https://forums.fedoraforum.org/showthread.php?322184-nmcli-(NetworkManager)-create-AP-(with-wpa-psk)-doesn-t-work

I tried downgrading my kernel version but had the same error with 4.14 and 4.9

Steps to reproduce

  1. have networking.networkmanager.enable = true;
  2. Be connected to Ethernet and have an AP-capable WLAN chipset
  3. Try to create a secured hotspot i.e. with nmcli dev wifi hotspot ifname <wireless-iface-name> ssid test password "test1234"

Technical details

cxandru commented 5 years ago

Can anyone reproduce this? Also, how do I add the bug flair?

worldofpeace commented 5 years ago

I tried this on Pantheon without issues. Can try GNOME 3 next, but it's likely tied to your wifi card.

worldofpeace commented 5 years ago

Also, how do I add the bug flair?

Do you mean nix run nixpkgs.nix-info -c nix-info -m?

cxandru commented 5 years ago

@worldofpeace I know it's not tied ultimately to my card because I was able to create a secured hotspot on linuxMint a day before I started installing NixOS, also creating an unsecured Hotspot works, as mentioned.

cxandru commented 5 years ago

Ok I have managed to get the log: If you compare it with the one in https://bugzilla.redhat.com/show_bug.cgi?id=1518190 it is nearly identical. Also search results for the various in-between errors pointed me again to fedora forums where the issue was closed after an update. In particular this bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1463245 emphasizes that the warning nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures is not the issue. Here are the relevant parts of the log:

Sep 06 13:49:37 Ondolinde nm-dispatcher[11238]: req:1 'down' [wlo1]: new request (1 scripts)
Sep 06 13:49:37 Ondolinde nm-dispatcher[11238]: req:1 'down' [wlo1]: start running ordered scripts...
Sep 06 13:49:37 Ondolinde wpa_supplicant[859]: wlo1: CTRL-EVENT-SCAN-FAILED ret=-100
Sep 06 13:49:37 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:37 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:37 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:49:37 Ondolinde wpa_supplicant[859]: Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
Sep 06 13:49:37 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:38 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:38 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: Using interface wlo1 with hwaddr 84:3a:4b:58:5c:24 and ssid "Ondolinde"
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: Interface initialization failed
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: interface state UNINITIALIZED->DISABLED
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: AP-DISABLED
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: Unable to setup interface.
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: Failed to initialize AP interface
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: interface state DISABLED->DISABLED
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: AP-DISABLED
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: hostapd_free_hapd_data: Interface wlo1 wasn't started
Sep 06 13:49:38 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:38 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:49:38 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:49:38 Ondolinde wpa_supplicant[859]: wlo1: CTRL-EVENT-DISCONNECTED bssid=84:3a:4b:58:5c:24 reason=3 locally_generated=1
Sep 06 13:50:02 Ondolinde NetworkManager[760]: <warn>  [1567770602.8102] device (wlo1): Activation: (wifi) Hotspot network creation took too long, failing activation
Sep 06 13:50:02 Ondolinde NetworkManager[760]: <warn>  [1567770602.8126] device (wlo1): Activation: failed for connection 'wifi-hotspot'
Sep 06 13:50:02 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:50:02 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:03 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:03 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:50:03 Ondolinde wpa_supplicant[859]: wlo1: Reject scan trigger since one is already pending
Sep 06 13:50:06 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:06 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:06 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:50:06 Ondolinde wpa_supplicant[859]: Note: nl80211 driver interface is not designed to be used with ap_scan=2; this can result in connection failures
Sep 06 13:50:06 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:07 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:07 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: Using interface wlo1 with hwaddr 84:3a:4b:58:5c:24 and ssid "Ondolinde"
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: Interface initialization failed
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: interface state UNINITIALIZED->DISABLED
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: AP-DISABLED
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: Unable to setup interface.
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: Failed to initialize AP interface
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: interface state DISABLED->DISABLED
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: AP-DISABLED
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: hostapd_free_hapd_data: Interface wlo1 wasn't started
Sep 06 13:50:07 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:07 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 06 13:50:07 Ondolinde kernel: IPv6: ADDRCONF(NETDEV_UP): wlo1: link is not ready
Sep 06 13:50:07 Ondolinde wpa_supplicant[859]: wlo1: CTRL-EVENT-DISCONNECTED bssid=84:3a:4b:58:5c:24 reason=3 locally_generated=1
cxandru commented 5 years ago

Just to make sure I tested this with the Archiso install image and the problem does not occur.

worldofpeace commented 5 years ago

Thanks for testing and verifying this @gregor-alexandru. There is a good amount of info here that someone could figure this out.

Though could you get the package versions that worked in Arch? (wpa_supplicant, networkmanager, kernel version)

And have you tried a newer kernel version?

cxandru commented 5 years ago

@worldofpeace yes, I originally and again afterwards tried it with kernel version 4.19. I also changed my package source to unstable and it didn't help. Arch versions are: wpa_supplicant: v2.9 networkmanager: 1.20.2-1 kernel: 5.2.11-arch-1-ARCH

worldofpeace commented 5 years ago

On unstable, where this works for me, we have networkmanager: 1.18.2 wpa_supplicant: 2.9 kernel: 5.2.11

On 19.03 it's wpa_supplicant: 2.8 networkmanager: 1.14.2

So there's a pretty big disparity between versions here, because it works in arch for you I have a feeling that maybe this isn't broken on unstable, just 19.03. Is it possible you could try unstable?

cxandru commented 5 years ago

Do you know where I can actually find the available kernel versions? The entry in the wiki does not work anymore, pkgs.linuxPackages just spits out a lot of verbose stuff

worldofpeace commented 5 years ago

@gregor-alexandru Off the top of my head I don't recall a better way than

nix search linuxPackages_ 

or

nix repl '<nixpkgs>'
$ linuxPackages_ # tab completions
cxandru commented 5 years ago

Ok, I've now switched to unstable with your stated versions of the relevant packages. Sadly it's still broken, the messages are rather more cryptic than before:

Sep 07 01:24:41 Ondolinde sudo[1868]: earendil : TTY=pts/1 ; PWD=/home/earendil ; USER=root ; COMMAND=/run/current-system/sw/bin/nmcli con up wifi-hotspot
Sep 07 01:24:41 Ondolinde sudo[1868]: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 07 01:24:41 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 01:24:41 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 01:24:44 Ondolinde kernel: refused connection: IN=enp0s25 OUT= MAC=74:46:a0:3b:3f:2d:30:7c:5e:03:a2:00:08:00 SRC=117.93.71.129 DST=213.124.164.223 LEN=40 TOS=0x00 PREC=0x00 TTL=49 ID=19454 PROTO=TCP SPT=24708 DPT=80 WINDOW=58251 RES=0x00 SYN URGP=0 
Sep 07 01:24:53 Ondolinde kernel: refused connection: IN=enp0s25 OUT= MAC=74:46:a0:3b:3f:2d:30:7c:5e:03:a2:00:08:00 SRC=159.203.199.14 DST=213.124.164.223 LEN=40 TOS=0x00 PREC=0x00 TTL=243 ID=54321 PROTO=TCP SPT=37236 DPT=8084 WINDOW=65535 RES=0x00 SYN URGP=0 
Sep 07 01:25:06 Ondolinde NetworkManager[820]: <warn>  [1567812306.8446] device (wlo1): Activation: (wifi) association took too long, failing activation
Sep 07 01:25:06 Ondolinde NetworkManager[820]: <warn>  [1567812306.8469] device (wlo1): Activation: failed for connection 'wifi-hotspot'
Sep 07 01:25:06 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 01:25:07 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 01:25:07 Ondolinde sudo[1868]: pam_unix(sudo:session): session closed for user root

Interestingly I found this post on r/NixOS as the first result when searching for kernel: refused connection: https://www.reddit.com/r/NixOS/comments/9wplyg/kernel_refused_connection_ineth0_in_system/

worldofpeace commented 5 years ago

Which kernel?

cxandru commented 5 years ago

5.2.11

cxandru commented 5 years ago

Btw I also tried creating one with hostapd like so: https://discourse.nixos.org/t/nixos-access-point-via-hostapd/1060/4 and it also timed out, so this is not a networkManager issue.

cxandru commented 5 years ago

Log updated with NetworkManager logging messages set to debug:

Sep 07 09:12:28 Ondolinde sudo[5196]: earendil : TTY=pts/6 ; PWD=/home/earendil ; USER=root ; COMMAND=/run/current-system/sw/bin/nmcli con up wifi-hotspot ifname wlo1
Sep 07 09:12:28 Ondolinde sudo[5196]: pam_unix(sudo:session): session opened for user root by (uid=0)
Sep 07 09:12:28 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 09:12:28 Ondolinde kernel: iwlwifi 0000:24:00.0: Radio type=0x1-0x2-0x0
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <info>  [1567840348.8357] device (wlo1): supplicant interface state: disconnected -> disabled
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <info>  [1567840348.8358] device (wlo1): supplicant interface state: disabled -> disconnected
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <info>  [1567840348.8369] device (wlo1): Activation: (wifi) access point 'wifi-hotspot' has security, but secrets are required.
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <info>  [1567840348.8399] device (wlo1): Activation: (wifi) connection 'wifi-hotspot' has security, and secrets exist.  No new secrets needed.
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <info>  [1567840348.8541] device (wlo1): supplicant interface state: disconnected -> scanning
Sep 07 09:12:28 Ondolinde NetworkManager[820]: <debug> [1567840348.8541] device[0x189aed0] (wlo1): wifi-scan: scanning-state: scanning
Sep 07 09:12:32 Ondolinde NetworkManager[820]: <debug> [1567840352.1952] device[0x189aed0] (wlo1): wifi-scan: scan-done callback: successful
Sep 07 09:12:33 Ondolinde kernel: refused connection: IN=enp0s25 OUT= MAC=74:46:a0:3b:3f:2d:30:7c:5e:03:a2:00:08:00 SRC=185.175.93.14 DST=213.124.164.223 LEN=40 TOS=0x00 PREC=0x00 TTL=246 ID=62794 PROTO=TCP SPT=58229 DPT=44455 WINDOW=1024 RES=0x00 SYN URGP=0 
Sep 07 09:12:37 Ondolinde NetworkManager[820]: <debug> [1567840357.8446] device[0x189aed0] (wlo1): wifi-scan: scanning requested but not allowed at this time
Sep 07 09:12:37 Ondolinde NetworkManager[820]: <debug> [1567840357.8447] device[0x189aed0] (wlo1): wifi-scan: scheduled in 33 seconds (interval now 33 seconds)
Sep 07 09:12:40 Ondolinde NetworkManager[820]: <debug> [1567840360.4138] device[0x189aed0] (wlo1): wifi-scan: scan-done callback: successful
Sep 07 09:12:40 Ondolinde kernel: refused connection: IN=enp0s25 OUT= MAC=74:46:a0:3b:3f:2d:30:7c:5e:03:a2:00:08:00 SRC=218.65.5.176 DST=213.124.164.223 LEN=40 TOS=0x00 PREC=0x00 TTL=240 ID=63446 PROTO=TCP SPT=43156 DPT=445 WINDOW=1024 RES=0x00 SYN URGP=0 
Sep 07 09:12:48 Ondolinde NetworkManager[820]: <debug> [1567840368.7841] device[0x189aed0] (wlo1): wifi-scan: scan-done callback: successful
Sep 07 09:12:53 Ondolinde NetworkManager[820]: <warn>  [1567840373.8446] device (wlo1): Activation: (wifi) association took too long, failing activation
Sep 07 09:12:53 Ondolinde NetworkManager[820]: <warn>  [1567840373.8466] device (wlo1): Activation: failed for connection 'wifi-hotspot'
cxandru commented 5 years ago

Also my wifi card is Intel Corporation Centrino Advanced-N 6205 [Taylor Peak]

cxandru commented 5 years ago

Ok, I googled one of the other parts of the error message (Activation: (wifi) association took too long, failing activation), and found a thread of a ubuntu user having problems with his intel chipset (using the iwlwifi driver): https://ubuntuforums.org/showthread.php?t=2173329. I also found that iwlwifi apparently doesn't work very well with the 802.11n protocol. (Source: https://www.linux.com/tutorials/tips-and-tricks-get-most-out-your-linux-wifi/) So I added these two lines in a new file /etc/modprobe.d/iwlwifi.conf:

options iwlwifi 11n_disable=1
options iwlwifi wd_disable=0

And now it works!! Hooray! According to this post: https://superuser.com/questions/924559/wifi-connection-troubles-solved-why-does-my-fix-work the bt_coex_active option also sometimes seems to cause problems.

I couldn't find the .conf file in Arch, so I don't know how they do it. Also this does not appear to be a problem with all intel wifi cards as I had a friend fail to replicate it with a different intel wireless card (Intel Corporation Dual Band Wireless-AC 7265). Since I've gotten it to work on my setup I don't know if I should close this issue or wait for a fix to be introduced to the repo?

stale[bot] commented 4 years ago

Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on irc.freenode.net.
pmssantos commented 4 years ago

Thanks, @cxandru . Your solution also worked for me, with a IWL 5300 (I was trying to use it to obtain CSI - https://dhalperi.github.io/linux-80211n-csitool/) Out of curiosity, how did you guess that those two particular lines, in that particular file, would work?

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info