23

Running Arch Linux with kernel 3.6.11-12-ARCH+ on my Raspberry Pi.

I have a Linksys wifi usb dongle (WUSB54GC v3) that is running and working after I execute the following commands:

$> sudo ifconfig wlan0 up
$> sudo iwlist scan
$> sudo iwconfig wlan0 mode managed essid myssid key "mykey" retry 7
   # Only had to do this next one the first time
$> sudo wpa_passphrase myssid "mypassword" > /etc/wpa_supplicant/wpa_supplicant.conf 
$> sudo wpa_supplicant -B -Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
$> sudo dhcpcd wlan0

How do I get wifi on this device to work every time after booting? Eventually I want to deploy it in location without a wired connection (hence the wifi), but I obviously can't do that if I have to manually start/connect the wifi every time.

  • Wireless is best managed via a daemon such as network-manager or wicd. – jordanm Jun 24 '13 at 3:34
  • 1
    Did you try this instruction to automatically connect to wireless networks: wiki.archlinux.org/index.php/Netcfg – Raza Jun 24 '13 at 4:56
  • 3
    netcfg is depreciated in favour of netctl (not sure if that change has been reflected in the ARM respin of Arch yet though), but yes that is the way to handle your network config. – fukawi2 Jun 24 '13 at 5:18
18

You should use netctl. It is the Arch Linux built in network management system. If it isn't already installed (it should be though), run pacman -Syu netctl then look in /etc/netctl. There are example configuration files in /etc/netctl/examples.

To get up and running quickly:

  1. Make note of the device name for your wireless adapter. Replace all instances of wlan0 in my examples with the name that matches your setup.
  2. Ensure you have installed the required packages.

    pacman -Syu wpa_supplicant dhcpcd

    1. wpa_supplicant is required for WPA protected access points, and dhcpcd is required to get an IP from any network using a DHCP server, as listed on the Arch Linux wiki.
  3. Copy an appropriate example:

    cp /etc/netctl/example/wireless-wpa /etc/netctl/somedescriptivename

  4. Edit your new config at /etc/netctl/somedescriptivename to fit your setup.
  5. Enable the netctl-auto service for your wireless adapter. Again, replace wlan0 with the device name for your setup.

    systemctl enable netctl-auto@wlan0.service

A few things to note:

  • netctl will automatically connect to any profiles you have in /etc/netctl when you move into range of the access point
  • This setup will only work with profiles using Security=wpa-configsection and Security=wpa.
  • Disable all previously enabled wifi profiles using netctl disable profilename otherwise netctl will start them twice at boot once netctl-auto is enabled.

For more information please refer to the Netctl wiki entry.

  • that netctl-auto list returns no profiles, whereas 4 are configured and work with manual netctl is expected or anormal ? How can I use netctl-auto switch-to X if there are seemingly no valid X values ? I find the netctl-auto arch wiki entry surprisingly unhelpful, maybe you know where to find a better doc ? – Nikana Reklawyks Feb 3 '17 at 18:55
  • Nikana, I don't use netctl-auto very much, but just a few tips: 1. netctl-auto is for wireless connections only. If you're looking to use it for ethernet, use netctl-ifplugd. 2. Make sure you do not use wpa-config as the security method, and instead of wpa-configsection or wpa. Profiles will not show up when using wpa-config – Jacob Wiltse Feb 10 '17 at 20:23
  • Thank you. Unfortunately for future viewers, my setup works now, not that I recall doing anything special. netctl-auto list returns a bunch of profiles as it should. I think maybe one of my profiles was not compatible with netctl-auto because of this no-wpa-config requirement, which prevented all of them from showing up. – Nikana Reklawyks Feb 10 '17 at 20:49
  • As mentioned in my answer, you need to remove profiles created with netctl before enabling netctl-auto. Then, after starting netctl-auto, re-add them. – johny why Dec 8 '19 at 21:52
  • 1
    @johnywhy it's actually not true that you need to "remove" the profiles. You simply need to disable them, as per the netctl wiki entry. netctl-auto will automatically enable them as you move into range of a given SSID. Please refer to the notes in wiki.archlinux.org/index.php/Netctl#Wireless – Jacob Wiltse Dec 15 '19 at 7:10
6

An easier way that eliminates some of the guesswork on how to make profiles for netctl (taken from the netctl page on the arch wiki):

Step 1. Setup wireless internet manually, using wpa_supplicant as described in the OP. If your system doesn't have it installed do $ pacman -S wpa_supplicant.

Step 2. You'll also need dialog package, so $ pacman -S dialog. Then, you could either reboot your system or disconnect from your wireless network.

Step 3. Run $ wifi-menu -o, then go through the very straightforward Windows/Mac-esque settings. You can check the preset value of your system's network id via $ sudo netctl list. The value would be in the format of wlan098-SSID. (where SSID = your WLAN's name)

Step 4. Finally run $ netctl enable wlan098-SSID and reboot the system $ reboot

Still, occasionally you might get an error message with something like temporarily unable to resolve name or something, but just try pinging again and it should work.

  • Without netctl-auto, you won't reconnect automatically as hotspots come within range. See my answer for set up. – johny why Dec 8 '19 at 21:56
3

I believe all other answers are flawed, as explained in my comments on them.

These steps will auto-connect to the strongest hotspot. Tested on a standard arch install with systemd (may work on other OS's):

One-time setup:

Alternatively, just disable them, as explained by @JacobWiltse in a comment on another answer. wiki.archlinux.org/index.php/Netctl#Wireless

  • Obtain your WiFi device ID basename $(ls -d /sys/class/net/w*)

  • enable netctl-auto service. This is the service that will auto connect. systemctl enable netctl-auto@YourWifiDeviceID.service

Connect to a hotspot first time:

  • Run wifi-menu. Requires root. pkexec wifi-menu -o or sudo wifi-menu -o

Leave off the -o to see network passwords as you type it.

  • Arrow down, pick your desired connection, hit enter, accept connection-name, enter password.

Add more hotspots as needed. netctl-auto will automatically reconnect to the strongest available hotspot thereafter.

  • Answer improved – johny why Dec 8 '19 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.