======Répéteur wifi======
==== Ressources ====
* [[http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/|How to setup wifi on your raspberry pi via the command line]]
* [[https://rbnrpi.wordpress.com/project-list/wifi-to-ethernet-adapter-for-an-ethernet-ready-tv/|Wifi to ethernet adapter for an ethernet ready TV]]
* [[https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview|Setting up a raspberry pi as a wifi access point]]
* [[https://www.reddit.com/r/raspberry_pi/comments/35s1lt/how_to_make_a_raspberry_pi_powered_wifi_repeater/| How to make a raspberry pi powered wifi repeater]]
==== Répéteur wifi : Ethernet (eht0) vers Wifi (wlan0) ====
* Brancher la clé USB wifi
* Voir si la clé usb wifi est reconnue : '' iwconfig ''
* Installer les paquets suivant : '' apt-get install hostapd isc-dhcp-server ''
* Installer un gestionnaire Iptables : '' apt-get install iptables-persistent ''
* Configurer le DHCP : '' vi /etc/dhcp/dhcpd.conf ''
* Décommenter la ligne : ''authoritative;''
* Ajouter le contenu ci-dessous
* Editer le fichier //isc-dhcp-server// : '' vi /etc/default/isc-dhcp-server ''
* Indiquer l'interface qui servira pour le serveur DHCP : '' INTERFACES="wlan0" ''
* Éditer le fichier : '' vi /etc/network/interfaces ''
* Ajouter le contenu ci-dessous.
* Assigner l'IP static à l'interface wlan0 : '' ifconfig wlan0 192.168.42.2 ''
* Configurer le point d'accès (PA) : '' vi /etc/hostapd/hostapd.conf ''
* Ajouter le contenu ci-dessous
* Editer le fichier : '' vi /etc/default/hostapd ''
* Ajouter le contenu suivant : ''DAEMON_CONF="/etc/hostapd/hostapd.conf" ''
* Éditer le fichier '' vi /etc/sysctl.conf ''
* Ajouter la ligne : '' net.ipv4.ip_forward=1 ''
* Activer cette ligne immédiatement avec : '' sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward" ''
* Lancer les commandes suivantes pour activer la redirection :
* '' sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE ''
* '' sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT ''
* '' sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT ''
* Vérifier la prise en compte de ces commandes avec : '' sudo iptables -t nat -S '' ou '' sudo iptables -S ''
* Pour activer ces règles après chaque boot : '' sudo sh -c "iptables-save > /etc/iptables/rules.v4" ''
* //iptables-persistent// se charge d'appliquer les règles du dossier /etc/iptables après chaque redémarrage
* Éditer le fichier : '' vi /etc/wpa_supplicant/wpa_supplicant.conf ''
* Le contenu doit correspondre au contenu ci-dessous.
* Pour lancer la connexion wifi : ''wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf ''
* Voir les logs dans : // /var/log/wpa_supplicant.log //
* Redémarre le RPI : '' reboot ''
**Fichier /etc/dhcp/dhcpd.conf :**
subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.2;
default-lease-time 600;
max-lease-time 7200;
option domain-name "ClapasPi";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
**Fichier /etc/network/interfaces :**
auto lo
# ETH0 (Ethernet)
iface lo inet loopback
iface eth0 inet dhcp
# WLAN0 (Wifi)
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.42.2
netmask 255.255.255.0
**Fichier /etc/hostapd/hostapd.conf :**
interface=wlan0
driver=nl80211
ssid=ClapasPi
country_code=FR
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
# Sécurité WPA
wpa=2
wpa_passphrase=
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
wpa_pairwise=CCMP
wpa_group_rekey=86400
# Use 150Mbps with wifi n
ieee80211n=1
wme_enabled=1
**Fichier /etc/wpa_supplicant/wpa_supplicant.conf :**
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid=""
psk=""
# Les lignes ci-dessous me semble optionnelle :
# Protocol type can be: RSN (for WPA2) and WPA (for WPA1)
#proto=RSN
# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
#key_mgmt=WPA-PSK
# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
#pairwise=TKIP
#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
#auth_alg=OPEN
}
==== Répéteur wifi : WIfi (wlan1) vers Wifi (PA) (wlan0) ====
* Brancher en premier la clé usb wifi qui servira en tant que point d'accès (wlan0)
* Branche en second la clé usb wifi qui servira à se connecter à internet (wlan1)
* Voir si les clés usb wifi sont reconnues : '' iwconfig ''
* Éditer le fichier : '' vi /etc/network/interfaces ''
* Ajouter le contenu ci-dessous.
* Éditer le fichier : '' vi /etc/wpa_supplicant/wpa_supplicant.conf ''
* Le contenu doit correspondre au contenu ci-dessus.
* Redémarre le RPI : '' reboot ''
** Fichier /etc/network/interfaces :**
auto lo
iface lo inet loopback
iface eth0 inet manual
auto wlan0
allow-hotplug wlan0
# Wlan0 pour se connecter à internet
#iface wlan0 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
# Wlan0 en tant que Point d'acccès (eht0 vers wlan0)
iface wlan0 inet static
address 192.168.42.1
netmask 255.255.255.0
# Règles IPTABLE pour PA (eth0 vers wlan0) chargée au démarrage [jpm - 28-05-2016]
iptables-restore < /etc/iptables.ipv4.nat
# Wlan1 pour se connecter à internet si wlan0 est en point d'accès (PA)
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf