====== Wifi ====== ---- ===== Configuration ===== ==== via raspi-config ==== Lancer l'utilitaire de configuration : sudo raspi-config Configurer le réseau Wifi en allant dans le menu « Network Options » puis « Wifi ». Répondre aux questions : * Pays * SSID du réseau * Mot de passe du réseau ==== via fichier de configuration ==== Renseigner le fichier /etc/wpa_supplicant/wpa_supplicant.conf. Les informations sont à ajouter après les 2 premières lignes : ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=FR network={ ssid="xxx" psk="xxx" } Si le Wifi utilise une clef WEP ajouter la ligne suivante après la ligne psk : key_mgmt=NONE === Crypter le mot de passe === Pour éviter d'indiquer le mot de passe en clair dans le fichier on utilisera la commande : sudo wpa_passphrase puis on indiquera le mot de passe correspondant. En réponse on obtiendra une clef PSK à renseigner dans le fichier de configuration à la place du mot de passe en clair. === Prise en compte des modifications === sudo wpa_cli -i wlan0 reconfigure ---- [[all:bibles:materiel:raspberry:wifi|Haut de page]] ===== Désactivation ===== ==== Désactivation manuelle Wifi/Bluetooth ==== === Temporairement jusqu'au prochain redémarrage === systemctl stop wpa_supplicant systemctl stop bluetooth systemctl stop hciuart === Persistant === systemctl disable wpa_supplicant systemctl disable bluetooth systemctl disable hciuart ==== Par configuration ==== Ouvrir le fichier /boot/config.txt sur Raspberry PI OS ou /boot/firmware/config.txt sur Ubuntu Mate et ajouter les lignes suivantes après la ligne //#Additional overlays and parameters are documented /boot/overlays/README// dtoverlay=disable-wifi dtoverlay=disable-bt Redémarrer le raspberry PI. ---- [[all:bibles:materiel:raspberry:wifi|Haut de page]] ===== Hotspot Wifi ===== Pour que le Wifi fonctionne commencer avant tout par configurer le pays via raspi-config et le menu « Localisation Options / WLAN Country » ==== Installation ==== === dnsmasq === * Installer le paquet sudo apt install dnsmasq * Editer le fichier /etc/dhcpcd.conf pour ajouter les 2 lignes suivantes à la fin : interface wlan0 static ip_address=192.168.4.1/24 * Editer le fichier /etc/dnsmasq.conf pour ajouter les 2 lignes suivantes à la fin : interface=wlan0 dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h === hostapd === * Installer le paquet sudo apt install hostapd * Créer le fichier /etc/hostapd/hostapd.conf en y ajoutant les lignes suivantes : # This is the name of the WiFi interface we configured above interface=wlan0 # Use the nl80211 driver with the brcmfmac driver driver=nl80211 # This is the name of the network ssid= # Use the 2.4GHz band hw_mode=g # Use channel 6 channel=6 # Enable 802.11n ieee80211n=1 # Enable WMM wmm_enabled=1 # Enable 40MHz channels with 20ns guard interval ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] # Accept all MAC addresses macaddr_acl=0 # Use WPA authentication auth_algs=1 # Require clients to know the network name ignore_broadcast_ssid=0 # Use WPA2 wpa=2 # Use a pre-shared key wpa_key_mgmt=WPA-PSK # The network passphrase wpa_passphrase= # Use AES, instead of TKIP rsn_pairwise=CCMP * Editer le fichier /etc/default/hostapd pour modifier la ligne #DAEMON_CONF DAEMON_CONF="/etc/hostapd/hostapd.conf" ==== Prise en compte des modifications ==== sudo systemctl unmask hostapd sudo systemctl restart hostapd dnsmasq ==== Source ==== [[https://les-enovateurs.com/hotspot-wifi-raspberry-pi| Hotspot Raspberry Pi]] ==== Dépannage ==== === Non démarrage automatique du hotspot === Visiblement le hotspot ne démarre pas automatiquement au démarrage du PI. Ajout dans la crontab d'un redémarrage du service 5s après le démarrage. @reboot sleep 5 && /usr/bin/systemctl restart hostapd ---- [[all:bibles:materiel:raspberry:wifi|Haut de page]] ===== Trucs & Astuces ===== ==== Recherche des réseaux disponibles ==== sudo iwlist wlan0 scan | egrep 'Cell |Encryption|Quality|Last beacon|ESSID' ==== Liste des réseaux avec la puissance ==== sudo iw dev wlan0 scan | egrep "signal|SSID" ---- [[all:bibles:materiel:raspberry:wifi|Haut de page]] ===== Dépannage ===== [[all:bibles:linux:reseau:ssh#connexion_aleatoire|Connexion aléatoire en SSH]] ---- [[all:bibles:materiel:raspberry:wifi|Haut de page]]