Point d’accès wifi avec un Raspberry Pi

raspberry-ban

Nous avons récemment eu besoin d’avoir un point d’accès sur le Raspberry Pi. Cet article a pour but de faire un petit rappel lorsque l’on va en avoir de nouveau besoin!

Tout d’abord, nous allons commencer par installer le firmware pour le dongle USB :

apt-get install zd1211-firmware

Petite erreur que j’avais avec un freeze du raspberry (dmesg) :

[   43.500170] usb 1-1.3: Could not load firmware file zd1211/zd1211b_ub. Error number -2
[   43.500204] zd1211rw 1-1.3:1.0: couldn't load firmware. Error number -2

Une fois le dongle USB installé sur notre raspberry pi, on configure le serveur DHCPD sur l’interface wifi.

sudo apt-get install isc-dhcp-server
sudo vi /etc/dhcp/dhcpd.conf
sudo ifconfig wlan0 192.168.3.1 netmask 255.255.255.0
sudo /etc/init.d/isc-dhcp-server start

Dans mon cas, j’ai choisi de mettre comme adresse sur notre interface wifi 192.168.3.1

Pour faire le hostspot wifi, j’ai choisi hostapd

sudo apt-get install hostapd
sudo vi /etc/hostapd/hostapd.conf

La configuration est la suivante :

# Configuration récupère sur http://doc.ubuntu-fr.org/hostapd
# interface wlan du Wi-Fi
interface=wlan0
 
# nl80211 avec tous les drivers Linux mac80211
driver=nl80211
 
# Nom du spot Wi-Fi
ssid=oversimple
 
# mode Wi-Fi (a = IEEE 802.11a, b = IEEE 802.11b, g = IEEE 802.11g)
hw_mode=g
 
# canal de fréquence Wi-Fi (1-14)
channel=8
 
#WPA2-PSK-CCMP
wpa=2
wpa_passphrase=oversimple
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
 
# Beacon interval in kus (1.024 ms)
beacon_int=100
 
# DTIM (delivery trafic information message)
dtim_period=2
 
# Maximum number of stations allowed in station table
max_num_sta=255
 
# RTS/CTS threshold; 2347 = disabled (default)
rts_threshold=2347
 
# Fragmentation threshold; 2346 = disabled (default)
fragm_threshold=2346

On peut exécuter hostapd :

hostapd -d /etc/hostapd/hostapd.conf

Cependant, si l’on désire avoir notre point d’accès wifi au démarrage du raspberry , il faut configurer l’interface wifi avec une IP Fixe :

vi /etc/network/interfaces
 
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.3.1
netmask 255.255.255.0

On édite le fichier de config pour le démarrage de hostapd:

 sudo vi /etc/default/hostapd

Le contenu :

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.3.1
netmask 255.255.255.0

On édite dans le fichier /etc/default/hostapd afin de pouvoir sélectionner la configuration requise :

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Puis on active le tout au démarrage :

sudo update-rc.d hostapd enable
sudo update-rc.d isc-dhcp-server enable

Si vous avez besoin que le raspberry fasse une passerelle, il faut activer l’ip forwarding afin que les 2 interfaces(eth0 & wlan0) puissent communiquer.

It’s Oversimple, isn’t it?