- Wi-Fi
- Prerequisites
- iwd
- wpa_supplicant
- Automatic Configuration on System Boot
- Launching udhcpc through wpa_cli actions
- Automatic Reconnection when WIFI signal is lost
- Troubleshooting
- Broadcom Wi-Fi Chipset Users
- Rfkill
- Setting up WiFi Hotspot at the Boot up for Linux Devices
- Table of Contents
- Create a WiFi hotspot in Ubuntu 18.04
- Edit WiFi hotspot settings in Ubuntu 18.04
- Option 1: Edit the hotspot configuration file.
- Option 2: NM Connection Editor.
Wi-Fi
This page describes how to set up a wireless network connection with WPA encryption.
Choose a wireless daemon between
Prerequisites
iwd
Iwd (iNet wireless daemon) is a wireless daemon written by Intel and aiming at replacing Alpine Linux 3.10.
To do anything with iwd, it has to be running:
If it was not running, running iwctl .. commands will print
The name net.connman.iwd was not provided by any .service files Failed to retrieve IWD dbus objects, quitting.
and running just iwctl will say it is waiting for IWD to start.
List your available wifi device(s) (you probably have wlan0):
If you don’t know the SSID of your network you can run a scan and retrieve a list of all the detected networks:
$ iwctl station wlan0 scan && iwctl station wlp8s0 get-networks
$ iwctl station wlan0 connect
Note: iwd automatically stores network passphrases in the /var/lib/iwd directory and uses them to auto-connect in the future. If you run diskless Alpine, make sure to include this directory to the apkovl and commit:
# lbu add /var/lib/iwd && lbu commit -d
Note: Since version 1.10, iwd supports IPv6, but it is disabled by default. To enable it, add the following to the configuration file:
Contents of /etc/iwd/main.conf
Add a entry for the desired interface (e.g. wlan0 ):
Contents of /etc/network/interfaces
Note: You could instead use the iwd’s built-in network configuration by setting EnableNetworkConfiguration=true in /etc/iwd/main.conf
Contents of /etc/iwd/main.conf
Manually restart networking:
# rc-service networking restart
Your wifi interface should now be up and have a dedicated IP adress:
Useful link: Archlinux wiki page if you need more specific configuration.
wpa_supplicant
To list your available network interfaces:
Note: if you don’t see any wireless interfaces (e.g. wlan0 ), you probably need to load and/or install drivers/firmware.
Bring up the desired interface:
Note: If this errors with ioctl 0x8914 failed: No error information , that’s busybox ip ‘s way of saying your wireless radio is rfkill’d. See the Rfkill section for information on how to unblock your wireless radio.
Use this command to add your Wi-Fi network to wpa_supplicant:
# wpa_passphrase ‘ExampleWifiSSID’ ‘ExampleWifiPassword’ > /etc/wpa_supplicant/wpa_supplicant.conf
(Access point not broadcasting its SSID requires additional line scan_ssid=1 in the file wpa_supplicant.conf )
Note: the Wi-Fi SSID and password are case sensitive and the single quote before and after the SSID and password need to be there
Start wpa_supplicant in the foreground to make sure the connection succeeds.
# wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
If all is well, run it as a daemon in the background by setting the -B option.
# wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
Configure the interface with an IP address.
Sanity check: the interface should have a inet address.
Automatic Configuration on System Boot
Add a entry for the desired interface (e.g. wlan0 ):
Contents of /etc/network/interfaces
Sanity check: Make sure /etc/wpa_supplicant/wpa_supplicant.conf is the correct configuration for the wireless access point you want to connect to.
Manually restart (or start) networking.
# /etc/init.d/networking —quiet restart &
If all is well (feel free to confirm with the sanity checks),
Configure wpa_supplicant to start automatically on boot:
# rc-update add wpa_supplicant boot
Also make sure networking is set to automatically start on boot:
# rc-update add networking boot
Optional security precaution:
this is not necessary and on it.
Launching udhcpc through wpa_cli actions
With the above configuration, udhcpc will only run once at boot. If the Wifi isn’t available then, or the network changes in between, it needs to be notified. This is done through the wpa_cli action script in /etc/wpa_supplicant/wpa_cli.sh
Automatic Reconnection when WIFI signal is lost
To enable automatic reconnection when wifi signal is lost add these to config:
Contents of /etc/wpa_supplicant/wpa_supplicant.conf
# rc-update add wpa_cli boot
Troubleshooting
Broadcom Wi-Fi Chipset Users
The Broadcom chipset is quite popular among older computers. The b43 driver is included in the linux-lts or linux-edge kernel packages. However, you might need to compile the firmware manually for this chipset as it is not included in linux-firmware for some cargs.
You can check if you have a Broadcom chipset by using lspci:
Now we have everything to download the proprietary driver and extract the firmware from it:
# export FIRMWARE_INSTALL_DIR=»/lib/firmware» $ wget http://www.lwfinger.com/b43-firmware/broadcom-wl-5.100.138.tar.bz2 $ tar xjf broadcom-wl-5.100.138.tar.bz2 # b43-fwcutter -w «$FIRMWARE_INSTALL_DIR» broadcom-wl-5.100.138/linux/wl_apsta.o
More information can be found here.
Now you need to use modprobe so the device will show up:
Now continue with the normal instructions.
Rfkill
Many laptops have a hardware button (or switch) to turn off wireless card, however, the card can also be blocked by kernel. This can be changed using rfkill. To show the current of your Wi-Fi:
~ $ rfkill list 0: phy0: wlan Soft blocked: no Hard blocked: no
If the card is hard-blocked, use the hardware button or switch to unblock it. If the card is not hard-blocked but soft-blocked, use the following command:
Setting up WiFi Hotspot at the Boot up for Linux Devices
Most of the mobile robot platform uses Linux based Single board computer for onboard computation and these SBCs typically have WiFi or an external WiFi dongle can also be attached. While testing/debugging we need to continuously monitor the performance of the robot which makes it very important to have a remote connection with our robot. So, in this tutorial, we will help you in setting up the WiFi hotspot at the boot for Linux devices like Nvidia Jetson and Intel NUC. We will start with the procedure to set up the WiFi hotspot and then we will discuss how to change Wi-Fi hotspot settings in Ubuntu 18.04 to start it at bootup.
Table of Contents
Create a WiFi hotspot in Ubuntu 18.04
This section will help you in setting up the WiFi hotspot at the boot for Linux devices.
- To create a Wi-Fi hotspot, the first turn on the Wi-Fi and select Wi-Fi settings from the system Wi-Fi menu.
- In the Wi-Fi settings window, click on the menu icon from the window upper right-hand side corner, and select turn On Wi-Fi hotspot.
- A new Wi-Fi hotspot always uses AP mode in Ubuntu 18.04, and the network SSID and password, as well as the security type (WPA/WPA2 is used by default in Ubuntu 18.04), are presented on the next screen which is displayed immediately after enabling the Wi-Fi hotspot.
If you are ok with the defaults and don’t want to change anything, that’s all you have to do to create a Wi-Fi hotspot in Ubuntu 18.04.
Edit WiFi hotspot settings in Ubuntu 18.04
There are two ways to edit hotspot settings (like the network SSID and password) which will be discussed in this section.
Option 1: Edit the hotspot configuration file.
- After creating a hotspot for the first time, a file called hotspot is created which holds some settings. So make sure to create a hotspot first or else this file does not exist.
- In this file you can configure the network SSID it appears as ssid = under [wifi] ), the Wi-Fi password is the value of psk= under [wifi-security] ), and other settings as required.
sudo nano /etc/NetworkManager/system-connections/Hotspot
sudo systemctl restart NetworkManager
Option 2: NM Connection Editor.
NM connection editor also allows you to modify the hotspot Wi-Fi mode, band etc. It can be started by pressing Alt + F2 or using this command:
All changes can be made directly in the nm-connection-editor in its corresponding tab. After making any changes using nm-connection-editor, you’ll need to restart Network Manager.
sudo systemctl restart NetworkManager
To make sure all settings are preserved, start a hotspot by selecting turn On Wi-Fi Hotspot from the Wi-Fi System Settings once. Use the Connect to Hidden Network option for subsequent uses, then select the connection named Hotspot and click Connect.
Updated: November 11, 2019