iwconfig
apt-get install hostapd isc-dhcp-server
apt-get install iptables-persistent
vi /etc/dhcp/dhcpd.conf
authoritative;
vi /etc/default/isc-dhcp-server
INTERFACES=“wlan0”
vi /etc/network/interfaces
ifconfig wlan0 192.168.42.2
vi /etc/hostapd/hostapd.conf
vi /etc/default/hostapd
DAEMON_CONF=“/etc/hostapd/hostapd.conf”
vi /etc/sysctl.conf
net.ipv4.ip_forward=1
sh -c “echo 1 > /proc/sys/net/ipv4/ip_forward”
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
sudo iptables -t nat -S
ou sudo iptables -S
sudo sh -c “iptables-save > /etc/iptables/rules.v4”
vi /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -D wext -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
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=<mot-de-passe> 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="<YOUR-SSID>" psk="<YOUR-PASSWORD>" # 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 }
iwconfig
vi /etc/network/interfaces
vi /etc/wpa_supplicant/wpa_supplicant.conf
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