ライナックスの無線接続

Quelques fichiers de configuration que j'utilise pour configurer le wifi sous Linux.

/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
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf

#address 192.168.1.25
#netmask 255.255.255.0
#network 192.168.1.0
#gateway 192.168.1.1
#dns-nameservers 192.168.1.1


/etc/wpa_supplicant
ctrl_interface=/var/run/wpa_supplicant
ap_scan=2

network={
#priority=0
#driver=wext
#bssid={Un_BSSID_MAC_ADRESS}
ssid="Mon_SSID"
scan_ssid=1
#ap_scan=1
#auth_alg=OPEN
pairwise=CCMP TKIP
group=TKIP
proto=RSN WPA
key_mgmt=WPA-PSK
psk={Un_PSK_Encodé}
}


/etc/init.d/wpa (source:Ubuntu.com)
#!/bin/bash
### BEGIN INIT INFO
# Provides: wpa
# Required-Start: $network $syslog $local_fs
# Required-Stop: $network $syslog $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop script for wpa supplicant
# Description: Custom start/stop script for wpa_supplicant.
### END INIT INFO

SELF=`basename $0`
WPA=wpa_supplicant
PROGRAM=/sbin/${WPA}
CONF=/etc/${WPA}.conf
INTERFACE=wlan0
DRIVER=wext
DAEMONMODE="-B"
LOGFILE=/var/log/$WPA.log

function start() {

# TODO: Support multiple interfaces and drivers
OPTIONS="-c $CONF -i $INTERFACE -D $DRIVER $DAEMONMODE"

## You can remove this if you are running 8.10 and up.
# Ubuntu 8.10 and up doesn't need the -w anymore..
# And the logfile option is not valid on 8.04 and lower
local ver=$(lsb_release -sr | sed -e 's/\.//g');
[ $ver -lt 810 ] && OPTIONS="$OPTIONS -w" && LOGFILE=""
##

# Log to a file
[ -n "$LOGFILE" ] && OPTIONS="$OPTIONS -f $LOGFILE"

echo " * Starting WPA Supplicant"
eval $PROGRAM $OPTIONS
}

function stop() {
echo " * Stopping WPA Supplicant"
pkill $PROGRAM
# Si pkill ne marche pas utiliser l'autre méthode
#kill -9 `pgrep $WPA`
}

function debug() {
stop
DAEMONMODE="-ddd"
start
}

function restart() {
stop
start
}

function status() {
pgrep -lf $PROGRAM
}

function usage() {
echo "Usage: $SELF "
return 2
}

case $1 in
start|stop|debug|status) $1 ;;
*) usage ;;
esac


Activer une interface
sudo ifup wlan0
Désactiver une interface
sudo ifdown wlan0

Consulter la doc de wpa_supplicant.conf
gzip -dc /usr/share/doc/wpasupplicant/README.wpa_supplicant.conf.gz |less
Automatiser le lancement du Daemon WPA Supplicant
sudo update-rc.d wpa defaults
Ou à la place de defaults mettre les niveaux d'exécution
update-rc.d wpa start 90 2 3 4 5 . stop 10 0 1 6 .