|
|
||||||||||
Un Hotpot Complet !
|
Cette page décris la mise en place d'un point d'accès WiFi sous Linux.
Ce point d'accès seras OUVERT mais demanderas une authentification auprès de l'utilisateur (Payant ou non), sans quoi, il n'auras pas accès à Internet ou un accès restreint.
Le plus de ce tutoriel, est si vous êtes comme moi, ne voulans pas acheter de certificats aupres d'autorithé de certification, Chillispot vas vous envoyé de messages d'érreurs à chaques connexions cliente pour lui indique un certificat non valide.
Quel est l'idiot qui vas accepter cella ? Surtout si l'on lui demande de payé ?
Mais soyez rassurés : Les paiements restent en SSL avec certification VALIDE aupres de l'autorithé de certification : En effet je ne veux en aucun cas gèrer les transactions : C'est PayPal qui s'en charge ! Donc rien à craindre au niveau sécuritée !
Tout d'abord, voyons l'architecture physique mise en place pour ce projet :
Ce matériel est connecter de la façon suivante :
(Image non disponible).
Pour commencer, nous intallons une Debian de base sur le serveur.
Une installation la plus légère possible à été mise en place. Le nom de la machine est HotSpot.
Commande entrée :
Ce styleindique une commande à écrire.
Sortie écran :
Ce style indique ce que vous recevez comme message l'ors de la saisie de la commande.
Texte orginal :
Ce style indique le texte orginal dans un fichier de configuration par exemple.
Texte modifié :
Ce style indique ce que j'ai modifier dans un fichier de configuration par exemple.
Texte ajouté :
Ce style indique ce que j'ai ajouter en complement d'un fichier de configuration par exemple.
Une fois installée je me suis empressé d'installer SSH (apt-get install ssh) pour pouvoir débrancher mon clavier de cette machine et la remètre dans ma baie de brassage.
Mais nous devons partir sur des bases propre : Une mise à jours du sytème s'impose.
HotSpot:~# apt-get dist-upgrade
et efin on redemarre la machine pour que le nouveau noyau prenne le relais avec un "init 6".
La carte WiFi Alpha Network 500mw fonctionne sous un chipset RTL8187.
Je vais donc compiler un driver à partir des sources du fabricant qui à eû la bonne idée de les fournir.
Téléchargement des sources :
HotSpot:~# wget ftp://202.65.194.212/cn/wlan/rtl8187_linux_26.1025.0328.2007.tar.gz
Décompression de celles-ci :
HotSpot:~# tar -xzvf rtl8187_linux_26.1025.0328.2007.tar.gz
HotSpot:~# cd rtl8187_linux_26.1025.0328.2007
On on commence à compiller tout ça !
Mais j'ai installer un système Debian très basique !
Nous devons donc installer les paquets pour compiler ce driver :
HotSpot:~/rtl8187_linux_26.1025.0328.2007# apt-get install module-assistant
HotSpot:~/rtl8187_linux_26.1025.0328.2007# module-assistant prepare
Voilà, maintenant je peut réellement compiler mon driver :
HotSpot:~/rtl8187_linux_26.1025.0328.2007# ./makedrv
Maintenant que notre driver est compiler, il faut le mètre en place en copiant les modules aux bons endrois :
HotSpot:~/rtl8187_linux_26.1025.0328.2007# cd ieee80211/
HotSpot:~/rtl8187_linux_26.1025.0328.2007/ieee80211# cp *.ko /lib/modules/2.6.18-5-686/kernel/drivers/net/wireless/
HotSpot:~/rtl8187_linux_26.1025.0328.2007/ieee80211# cd ..
HotSpot:~/rtl8187_linux_26.1025.0328.2007# cd rtl8187/
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# cp *.ko /lib/modules/2.6.18-5-686/kernel/drivers/net/wireless/
On regénères la base des modules :
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# depmod -a
Et enfin on les chargent manuellement pour effectuer un test :
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe ieee80211_crypt-rtl
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe ieee80211_crypt_wep-rtl
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe ieee80211_crypt_tkip-rtl
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe ieee80211_crypt_ccmp-rtl
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe ieee80211-rtl
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# modprobe r8187
Nôtre Debian de base ne sait pas se connecter à un point d'accès WiFi.
Je lui installe donc les paquets pour lui permètre de se connecter à un point d'accès :
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# apt-get install wireless-tools
Maintenant, je peut configurer ma connexion WiFi.
Ici, exemple avec un LiveBow de chez Wanadaube :
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# iwconfig wlan0 essid Wanadoo_a1b2
Indique le point d'accès sur lequel je veux me connecter.
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# iwconfig wlan0 key on
Mon point d'accès est crypté par WEP.
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# iwconfig wlan0 key XYXYXYXYXYXYXYXYXYXYXYXYXY
J'indique ma clef WEP.
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# iwconfig wlan0 mode Managed
Je lui indique que c'est en mode infrastructure.
HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# ifconfig wlan0 up
Je monte ma carte réseau (Démarre).
| HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# dhclient wlan0 Je lance une requette DHCP. |
|
| Internet Systems Consortium DHCP Client V3.0.4 Copyright 2004-2006 Internet Systems Consortium. All rights reserved. For info, please visit http://www.isc.org/sw/dhcp/ Listening on LPF/wlan0/00:c0:xx:xx:xx:xx Sending on LPF/wlan0/00:c0:xx:xx:xx:xx Sending on Socket/fallback DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8 DHCPOFFER from 192.168.1.1 DHCPREQUEST on wlan0 to 255.255.255.255 port 67 DHCPACK from 192.168.1.1 bound to 192.168.1.14 -- renewal in 270116 seconds. --> Ligne disant que tout est OK ! |
|
Maintenant que je sait que cella fonctionne, je vais mètre ma configuration réseau en dur sur le serveur.
Mise en place des modules au démarrage :
| HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# vim /etc/modules | |
# /etc/modules: kernel modules to load at boot time. loop |
|
Après, j'indique la configuration réseau :
| HotSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# vim /etc/network/interfaces | |
| # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface # The primary network interface auto eth0 auto wlan0 |
|
Et enfin on redémarre le serveur et nous aurons une configuration réseau toute propre !
otSpot:~/rtl8187_linux_26.1025.0328.2007/rtl8187# init 6
Nous allons installer un serveur WEB : Apache2, pour fournir au clients les pages web du HotSpot.
L'installation ? Très simple :
HotSpot:~# apt-get install apache2
Le serveur DNS vas nous permètre d'utiliser des nom usuels pour le HotSpot comme par exemple la page de connexion qui seras login.hotspot.
HotSpot:~# apt-get install bind
Ajout des définitions des nouvelles zones DNS:
| HotSpot:~# vim /etc/bind/named.conf.local | |
// zone "24.33.10.in-addr.arpa" { zone "24.168.192.in-addr.arpa" { |
|
Fichier de la zone "HotSpot" :
| HotSpot:~# vim /etc/bind/hotspot | |
$TTL 604800 login IN A 192.168.24.1 |
|
Reverse DNS de la zone HotSpot local:
| HotSpot:~# vim /etc/bind/db.10.33.24 | |
$TTL 86400 @ IN SOA dns.hotspot. root.hotspot. ( 253 IN PTR login.hotspot. |
|
Reverse DNS de la zone HotSpot Public:
| HotSpot:~# vim /etc/bind/db.192.168.24 | |
$TTL 86400 @ IN SOA hotspot. galoula.galoula.com. ( 1 IN PTR login.hotspot. |
|
On configure les redirecteurs :
| HotSpot:~# vim /etc/bind/named.conf.options | |
options { // from bind 9: fetch-glue no; // If there is a firewall between you and nameservers you want // query-source address * port 53; // If your ISP provided one or more IP addresses for stable forwarders { |
|
On configure la machine locale pour utilisé le nouveau DNS :
| HotSpot:~# vim /etc/hosts |
|
| 127.0.0.1 localhost 127.0.1.1 HotSpot.GALOULA.COM.local HotSpot 127.0.0.1 login.hotspot # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts |
|
On relance bind :
HotSpot:~# /etc/init.d/bind restart
HotSpot:~# apt-get install freeradius
| HotSpot:~# vim /etc/freeradius/clients.conf | |
secret = testing123 par secret = RadiusSecret |
|
ChilliSpot est le coeur de notre HotSpot, c'est lui qui gère le routeur WiFi est ses accès physiques.
Pour l'installé suffit de tapper cette commande :
HotSpot:~# apt-get install chillispot
Adresse IP du premier serveur RADIUS : 127.0.0.1
Secret partagé du RADIUS : RadiusSecret
Interface Ethernet où le serveur DHCP sera à l'écoute : eth0
URL du serveur UAM : http://login.hotspot/cgi-bin/hotspotlogin.cgi
URL de la page d'accueil de l'UAM : http://hotspot.galoula.com
Mot de passe partagé entre ChilliSpot et le serveur Web : ChilliSecret
| HotSpot:~# vim /etc/chilli.conf |
|
############################################################################## # TAG: fg # TAG: debug # TAG: interval # TAG: pidfile # TAG: statedir # TUN parameters # TAG: net # TAG: dynip # TAG: statip # TAG: dns1 # TAG: dns2 # TAG: domain # TAG: ipup # TAG: ipdown # Radius parameters # TAG: radiuslisten # TAG: radiusserver1 # TAG: radiusserver2 # TAG: radiusauthport # TAG: radiusacctport # TAG: radiussecret # TAG: radiusnasid # TAG: radiuslocationid # TAG: radiuslocationname # Radius proxy parameters # TAG: proxylisten # TAG: proxyport # TAG: proxyclient # TAG: proxysecret # DHCP Parameters # TAG: dhcpif # TAG: dhcpmac # TAG: lease # Universal access method (UAM) parameters # TAG: uamserver # TAG: uamhomepage # TAG: uamsecret # TAG: uamlisten # TAG: uamport # TAG: uamallowed # TAG: uamanydns # MAC authentication # TAG: macauth # TAG: macallowed # TAG: macpasswd # TAG: macsuffix |
|
Et nous devons lui mètre le script de connexion en place :
HotSpot:~# cp /usr/share/doc/chillispot/hotspotlogin.cgi.gz /usr/lib/cgi-bin/
HotSpot:~# cd /usr/lib/cgi-bin
HotSpot:/usr/lib/cgi-bin# gunzip hotspotlogin.cgi.gz --> Répondre oui (y).
HotSpot:/usr/lib/cgi-bin# chmod a+x hotspotlogin.cgi
| HotSpot:/usr/lib/cgi-bin# vim /usr/lib/cgi-bin/hotspotlogin.cgi | |
#!/usr/bin/perl # chilli - ChilliSpot.org. A Wireless LAN Access Point Controller # Redirects from ChilliSpot daemon: # Shared secret used to encrypt challenge with. Prevents dictionary attacks. # Uncomment the following line if you want to use ordinary user-password # Our own path use Digest::MD5 qw(md5 md5_hex md5_base64); # Make sure that the form parameters are clean # Make sure that the get query parameters are clean # If she did not use https tell her that it was wrong. #Read form parameters which we care about #Read query parameters which we care about $reply =~ s/\+/ /g; $userurldecode = $userurl; $redirurldecode = $redirurl; $password =~ s/\+/ /g; # If attempt to login # Default: It was not a form request # If login successful # If login failed # If logout successful # If tried to login while already logged in # If not logged in yet # If login from smart client # If requested a logging in pop up window # If requested a success pop up window # If requested a logout pop up window # Otherwise it was not a form request #Generate the output function doTime() { function popUp(URL) { function doOnLoad(result, URL, userurl, redirurl, timeleft) { function doOnBlur(result) { # if (!window.opener) { #print "THE INPUT: $input"; if ($result == 2) { if ($result == 5) { if ($result == 2 || $result == 5) { if ($result == 1) { if ($reply) { print " if (($result == 4) || ($result == 12)) { if ($result == 11) { if (($result == 3) || ($result == 13)) { exit(0); |
|
Mise en place du pare-feu :
HotSpot:/usr/lib/cgi-bin# apt-get install iptables
Configuration du parre-feu.
Je n'ai pas utiliser le fichier d'exemple fournis avec chillispot, j'en ai crée un plus complexe, que voici :
| HotSpot:/usr/lib/cgi-bin# vim /etc/chilli.iptables | |
#!/bin/sh /etc/init.d/bind restart IPTABLES="/sbin/iptables" # REMISE à ZERO des règles de filtrage # Je veux que les connexions entrantes soient bloqué par défaut # Je veux que les connexions destinétre forwardéoient accepté par défaut # Je veux que les connexions sortantes soient accepté par défaut # J'accepte les packets entrants relatifs à connexions établies # Tout autorisé en LOCAL (loopback) #$IPTABLES -A INPUT -i $WAN -j ACCEPT # J'autorise les connexions HTTP # Je renvoie les connexions TCP entrantes sur le port RDP d'internet vers un serveur sur mon réseau Local # Je renvoie les connexions TCP entrantes sur le port RDP d'internet vers un serveur sur mon réau Local # J'autorise les connexions TCP entrantes sur le port 22 # J'autorise les connexions NFS entrantes sur le port 2049 # J'accepte le protocole ICMP (i.e. le "ping") depuis mon ré local et Intranet. # J'autorise les connexions TCP et UDP entrantes sur le port 53 # J'autorise les connexions TCP entrantes des principaux services : # J'autorise les connexions TCP entrantes sur le port 3990 # Je n'autorise plus rien venant de ChilliSpot, car ce sera lui qui vas # FIN des rè FIREWALLING # Je veux que mon systèasse office de "serveur NAT" echo "1" > /proc/sys/net/ipv4/ip_forward |
|
Puis le rendre éxécutable :
HotSpot:/usr/lib/cgi-bin# chmod +x /etc/chilli.iptables
On active ChilliSpot :
| HotSpot:~# vim /etc/default/chillispot | |
# /etc/default/chillispot |
|
HotSpot:/usr/lib/cgi-bin# apt-get install mysql-server mysql-client php4-mysql
Installation d'une interface d'administration conviviale :
HotSpot:/var/PayPal# apt-get install phpmyadmin
Installation de DialUpAdmin :
HotSpot:~# apt-get install freeradius-dialupadmin freeradius-mysql
HotSpot:~# echo "create database radius;" | mysql -u root -p
HotSpot:~# echo "grant all on radius.* to radius@'%' identified by 'motdepasse_sql'; flush privileges;" | mysql -u root -p
HotSpot:~# zcat /usr/share/doc/freeradius/examples/mysql.sql.gz | mysql -u root -p radius
HotSpot:~# echo "INSERT INTO radcheck(UserName,Attribute,op,Value) VALUES ('Galoula','User-Password','==','Test');" | mysql -u root -p radius
| HotSpot:~# vim /etc/freeradius/sql.conf | |
# # Connect info # Database table configuration # If you want both stop and start records logged to the # Allow for storing data after authentication authcheck_table = "radcheck" groupcheck_table = "radgroupcheck" usergroup_table = "usergroup" # Table to keep radius client info # Remove stale session if checkrad does not see a double login # Print all SQL statements when in debug mode (-x) # number of sql connections to make to server # number of seconds to dely retrying on a failed database # Safe characters list for sql queries. Everything else is replaced ####################################################################### ####################################################################### ####################################################################### # The default queries are case insensitive. (for compatibility with # Use these for case sensitive usernames. authorize_group_check_query = "SELECT ${groupcheck_table}.id,${groupcheck_table}.GroupName,${groupcheck_table}.Attribute,${groupcheck_table}.Value,${groupcheck_table}.op FROM ${groupcheck_table},${usergroup_table} WHERE ${usergroup_table}.Username = '%{SQL-User-Name}' AND ${usergroup_table}.GroupName = ${groupcheck_table}.GroupName ORDER BY ${groupcheck_table}.id" ####################################################################### accounting_update_query = "UPDATE ${acct_table1} \ accounting_update_query_alt = "INSERT into ${acct_table1} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', DATE_SUB('%S',INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0')" accounting_start_query = "INSERT into ${acct_table1} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', '%S', '0', '0', '%{Acct-Authentic}', '%{Connect-Info}', '', '0', '0', '%{Called-Station-Id}', '%{Calling-Station-Id}', '', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '%{Acct-Delay-Time}', '0')" accounting_start_query_alt = "UPDATE ${acct_table1} SET AcctStartTime = '%S', AcctStartDelay = '%{Acct-Delay-Time}', ConnectInfo_start = '%{Connect-Info}' WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' AND NASIPAddress = '%{NAS-IP-Address}'" accounting_stop_query = "UPDATE ${acct_table2} SET AcctStopTime = '%S', AcctSessionTime = '%{Acct-Session-Time}', AcctInputOctets = '%{Acct-Input-Octets}', AcctOutputOctets = '%{Acct-Output-Octets}', AcctTerminateCause = '%{Acct-Terminate-Cause}', AcctStopDelay = '%{Acct-Delay-Time}', ConnectInfo_stop = '%{Connect-Info}' WHERE AcctSessionId = '%{Acct-Session-Id}' AND UserName = '%{SQL-User-Name}' AND NASIPAddress = '%{NAS-IP-Address}'" accounting_stop_query_alt = "INSERT into ${acct_table2} (AcctSessionId, AcctUniqueId, UserName, Realm, NASIPAddress, NASPortId, NASPortType, AcctStartTime, AcctStopTime, AcctSessionTime, AcctAuthentic, ConnectInfo_start, ConnectInfo_stop, AcctInputOctets, AcctOutputOctets, CalledStationId, CallingStationId, AcctTerminateCause, ServiceType, FramedProtocol, FramedIPAddress, AcctStartDelay, AcctStopDelay) values('%{Acct-Session-Id}', '%{Acct-Unique-Session-Id}', '%{SQL-User-Name}', '%{Realm}', '%{NAS-IP-Address}', '%{NAS-Port}', '%{NAS-Port-Type}', DATE_SUB('%S', INTERVAL (%{Acct-Session-Time:-0} + %{Acct-Delay-Time:-0}) SECOND), '%S', '%{Acct-Session-Time}', '%{Acct-Authentic}', '', '%{Connect-Info}', '%{Acct-Input-Octets}', '%{Acct-Output-Octets}', '%{Called-Station-Id}', '%{Calling-Station-Id}', '%{Acct-Terminate-Cause}', '%{Service-Type}', '%{Framed-Protocol}', '%{Framed-IP-Address}', '0', '%{Acct-Delay-Time}')" ####################################################################### # Uncomment simul_count_query to enable simultaneous use checking ####################################################################### group_membership_query = "SELECT GroupName FROM ${usergroup_table} WHERE UserName='%{SQL-User-Name}'" ####################################################################### postauth_query = "INSERT into ${postauth_table} (id, user, pass, reply, date) values ('', '%{User-Name}', '%{User-Password:-Chap-Password}', '%{reply:Packet-Type}', NOW())" # |
|
| HotSpot:~# vim /etc/freeradius/radiusd.conf | |
## # The location of other config files and prefix = /usr # Location of config and logfiles. # # # pidfile: Where to place the PID of the RADIUS server. # user/group: The name (or #number) of the user/group to run radiusd as. # max_request_time: The maximum time (in seconds) to handle a request. # delete_blocked_requests: If the request takes MORE THAN 'max_request_time' # cleanup_delay: The time to wait (in seconds) before cleaning up # max_requests: The maximum number of requests which the server keeps # bind_address: Make the server listen on a particular IP address, and # port: Allows you to bind FreeRADIUS to a specific port. # # Port on which to listen. # Type of packets to listen for. # hostname_lookups: Log the names of clients or just their IP addresses # Core dumps are a bad thing. This should only be set to 'yes' # Regular expressions # Log the full User-Name attribute, as it was found in the request. # Log authentication requests to the log file. # Log passwords with the authentication requests. # usercollide: Turn "username collision" code on and off. See the # lower_user / lower_pass: # nospace_user / nospace_pass: # The program to execute to do concurrency checks. # SECURITY CONFIGURATION # # # PROXY CONFIGURATION # CLIENTS CONFIGURATION # The 'clients.conf' file contains all of the information from the old # SNMP CONFIGURATION # THREAD POOL CONFIGURATION # Limit on the total number of servers running. # Server-pool size regulation. Rather than making you guess # There may be memory leaks or resource allocation problems with # MODULE CONFIGURATION # PAP module to authenticate users based on their stored password # CHAP module # Pluggable Authentication Modules # Unix /etc/passwd style authentication # Reload the cache every 600 seconds (10mins). 0 to disable. # # # Extensible Authentication Protocol # Microsoft CHAP authentication # if use_mppe is not set to no mschap will # if mppe is enabled require_encryption makes # require_strong always requires 128 bit key # Windows sends us a username in the form of # The module can perform authentication itself, OR # Lightweight Directory Access Protocol (LDAP) | |