Wi-Fi from the console
5.1
Joining a Wi-Fi network without a desktop: on a base or core system, a server, or when X does not start. The usual commands are in the Handbook, section Wi-Fi:
# trame wifi scan
# trame wifi connect "MyNetwork" - wpa
# trame wifi status
With -, trame asks for the key without showing it. For menus in a
text screen, run trame-tui and open "Wi-Fi networks". This page
covers what the Handbook leaves out: how it works, hidden networks,
WPA3, doing it all by hand, and what to check when it fails.
How it works
trame wifi connect writes the Wi-Fi settings in /etc/network.conf
and runs /etc/init.d/network.sh restart. The script then:
- adds a block for the network to
/etc/wpa/wpa.conf, where every known network and its key is kept (root only); - starts
wpa_supplicant, which joins the network; - starts
udhcpcfor an address once the link is up.
At boot the same script runs in the background, so the boot never waits
for the Wi-Fi. Its messages go to /var/log/network.log.
The Wi-Fi keys of /etc/network.conf, if you prefer to edit it:
WIFI="yes": use the Wi-Fi instead of the cable;WIFI_INTERFACE:wlan0most of the time,iw devtells;WIFI_ESSID: the network name;WIFI_KEY_TYPE:WPA(WPA and WPA2),WEP,EAP(802.1x, eduroam), empty for an open network,ANYto try them all;WIFI_KEY: the key or password;WIFI_BSSID: the address of one access point, optional;WIFI_WPA_DRIVER:nl80211;wextfor some very old cards.
Then, as root:
# /etc/init.d/network.sh restart
Hidden network
A network that does not broadcast its name does not show in
trame wifi scan. Connect by name all the same:
# trame wifi connect "HiddenNetwork" - wpa
network.sh always writes scan_ssid=1, which makes wpa_supplicant
ask for the network by its name. If several access points share the
name, set WIFI_BSSID to the one you want.
WPA3
WIFI_KEY_TYPE="WPA" (the wpa of trame) writes a WPA-PSK block. It
works with WPA2 networks and with mixed WPA2/WPA3 ones, the default of
most boxes. A network set to WPA3 only needs the SAE method: the
wpa_supplicant of SliTaz has it, but network.sh and trame don't write
it yet. Connect by hand, as below, with this file.
By hand, without network.sh
The same steps as the script, one by one, as root. First stop
network.sh from managing the Wi-Fi, or it will start its own
wpa_supplicant at the next boot: set WIFI="no" in
/etc/network.conf. Then:
# iw dev
# ip link set wlan0 up
# iw dev wlan0 scan | grep SSID
Write the network in its own file. wpa_passphrase reads the key
from the keyboard and writes the block:
# umask 077
# echo 'ctrl_interface=/var/run/wpa_supplicant' > /etc/wpa/home.conf
# wpa_passphrase "MyNetwork" >> /etc/wpa/home.conf
For a WPA3-only network, write the file yourself instead:
ctrl_interface=/var/run/wpa_supplicant
network={
ssid="MyNetwork"
key_mgmt=SAE
sae_password="the Wi-Fi key"
ieee80211w=2
}
Start wpa_supplicant in the background, then ask for an address:
# wpa_supplicant -B -i wlan0 -c /etc/wpa/home.conf
# udhcpc -i wlan0
Check:
$ iw dev wlan0 link
$ ip addr show wlan0
To stop:
# killall udhcpc wpa_supplicant
# ip link set wlan0 down
To do it at every boot, put the ip link set, wpa_supplicant and
udhcpc lines at the end of /etc/init.d/local.sh.
Troubleshooting
No Wi-Fi interface: iw dev shows nothing. The driver or its
firmware is missing. trame hardware firmware names the firmware; the
Handbook has a firmware table,
and the Wi-Fi chips page goes further. At
boot, network.sh then prints "No Wi-Fi interface found, skipping
Wi-Fi setup".
The radio is off: a switch or a Fn key can turn it off. 1 in one
of these files means blocked:
$ cat /sys/class/rfkill/rfkill*/soft /sys/class/rfkill/rfkill*/hard
hard is the switch or key. soft can be cleared with the rfkill
tool:
# spk-add rfkill
# rfkill unblock wifi
network.sh stop and trame wifi disconnect also turn the radio off;
trame wifi connect or network.sh start turns it on again.
"not connected to MyNetwork after 20s (wrong key or out of
range?)": trame waits 20 seconds for the link. Check the key and
the signal (trame wifi scan), then the state of wpa_supplicant:
# wpa_cli -i wlan0 status
wpa_state=COMPLETED means the link is up; then the problem is the
address: try udhcpc -i wlan0 by hand.
"WPA key must be 8 to 63 characters": a WPA key is never shorter.
Check that the network is not open (none) or WEP.
Read the messages: after a boot, /var/log/network.log; after a
network.sh restart, the terminal; the driver and firmware, with:
$ dmesg | grep -i -e wlan -e firmware
Links
- Handbook: Wi-Fi, Wi-Fi firmware, the network.conf file
- Network profiles: several
network.conffiles, one per place - Wi-Fi chips
- wpa_supplicant, the project's site