
Installations des paquets nécessaires
sudo apt-get update sudo apt-get upgrade sudo apt-get install apache2 php libapache2-mod-php dnsmasq hostapd
/etc/hostapd/hostapd.conf
ctrl_interface=/var/run/hostapd ctrl_interface_group=0 interface=wlan0 # ou n'importe quelle autre interface wifi ssid=ssid_voulu hw_mode=g channel=7 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 driver=nl80211 country_code=FR wpa_key_mgmt=WPA-PSK wpa_passphrase=mot_de_passe_voulu rsn_pairwise=CCMP wpa_pairwise=TKIP
/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8) # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d auto wlan0 iface wlan0 inet static address 193.167.0.21 # adresse ip pour l'accès à la page web netmask 255.255.255.0 gateway 193.167.0.1 # en fonction du réseau network 193.167.0.1 # pareil
/etc/dnsmasq.conf
interface=wlan0 dhcp-range=wlan0,193.167.0.22,193.167.0.255,255.255.255.0,24h
accessPointDirectWifi.php
<?php usleep(15000000); // Pour lancement auto via crontab echo "\nKILL HOSTAPD\n\n"; exec('sudo pkill hostapd'); usleep(1000000); echo "\nKILL DHCPCD\n\n"; exec('sudo pkill dhcpcd'); // Dans le cas où il existe une configuration dhcpcd existante en plus de dnsmasq usleep(1000000); echo "\nKILL WPA_SUPPLICANT\n\n"; exec('sudo pkill wpa_supplicant'); // Dans le cas où wlan0->internet et user->wlan1 usleep(1000000); echo "\nLANCEMENT HOSTAPD\n\n"; echo shell_exec('sudo hostapd -B /etc/hostapd/hostapd.conf'); usleep(1000000); echo "\nLANCEMENT DHCPCD\n\n"; exec('sudo dhcpcd -f /etc/dhcpcd.conf'); // Dans le cas où il existe une configuration dhcpcd existante en plus de dnsmasq usleep(1000000); echo "\nLANCEMENT WPA_SUPPLICANT\n\n"; exec('sudo wpa_supplicant -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf'); // Dans le cas ou wlan0->internet et user->wlan1 usleep(1000000); echo "\nAJOUT DE LA ROUTE SERVEUR\n\n"; exec('sudo route add 0.0.0.0 gw 193.167.0.21 wlan0'); // Adresse ip pour l'accès à la page web et interface réseau choisie
sudo crontab -e
@reboot /usr/bin/php7.3 chemin_vers_script_php/accessPointDirectWifi.php
Redémarrage
sudo reboot