Wlan with wpa_supplicant under NixOS?

1

How to set up networking (wlan) with wpa_supplicant on NixOS? Whenever I try to connect to my local wlan network, I get CONN_FAILED as reason, which is a bit uninformative. It also tells me that my pks is not valid (WRONG_KEY) but I trible confirmed that it is right and I used the configuration with the very same key (git version controlled) on the network on my Archlinux box before and it worked.

musicmatze

Posted 2015-07-06T20:16:00.670

Reputation: 113

Answers

6

I doubt it will become any more informative than what you already have, yet here we go.

First we need to store our WPA2-PSK secrets:

       wpa_passphrase MyWifiSSID MySecretPassword > wpa_supplicant.conf

Now make sure you have stopped a Network Manager, if you use one, and issue all the following commands as sudo. We clean the interface (I call it wlan0):

        ip link set dev wlan0 down
        ip addr flush dev wlan0
        ip link set dev wlan0 up

Now we associate to the AP:

         wpa_supplicant -B -i wlan0 -Dnl80211 -c wpa_supplicant.conf
         dhclient wlan0

If the network is correctly configured, then you are done. If there are some errors in the DHCP configuration, you may be missing either the default gateway or the DNS servers. You can set them just as I am about to do in the case of a static IP.

If you do not have a DHCP server, or if you wish to give yourself a static IP (say, 192.168.1.200), then skip the last command above, and issue instead

         ip addr add 192.168.1.200/24 dev wlan0

Remember, 24 is the network mask in CIDR notation. If yours differs, please adjust accordingly. Once this is done, you will need a default gateway:

         ip route add default via 192.168.1.1 dev wlan0

where 192.168.1.1 is the address of your home router/gateway, and DNS servers,

         echo nameserver 8.8.8.8 >> /etc/resolv.conf
         echo nameserver 8.8.4.4 >> /etc/resolv.conf

This is it.

MariusMatutiae

Posted 2015-07-06T20:16:00.670

Reputation: 41 321

I will try this out asap, hang tight! – musicmatze – 2015-07-08T18:42:47.273

This works, I get wlan, but I still cannot ping in my internal network. – musicmatze – 2015-07-11T07:47:38.997

@musicmatze Perhaps dhcpd isn't running? Or not on that interface? – Daniel Jour – 2015-11-25T19:26:30.870

1@DanielJour No, that's not the problem. Most likely he did not setup a default gateway and the DNS servers. – MariusMatutiae – 2015-11-25T22:31:00.960

It works now. I'm not sure about DNS or gateway... I'll mark this as appropriate answer. – musicmatze – 2015-11-27T10:30:30.497