Configurer une connexion cliente wifi définit green0
Note: Ici, on copie et on colle directement dans le shell.
Pour mettre en place une connexion wifi pour une carte réseau définit green0 en tant que client, il faut renseigné un fichier de configuration.
cat << EOF > /etc/wpa_supplicant.green0 network={ ssid="Hotspot" psk="password" } EOF
Créer un script.
cat << EOF > /etc/init.d/wlan_green #!/bin/sh ######################################################################## # Begin $rc_base/init.d/wlan_green # # Description : Wireless client initscript # ######################################################################## . /etc/sysconfig/rc . ${rc_functions} case "${1}" in start) wpa_supplicant -B -i green0 -c /etc/wpa_supplicant.green0 echo $! > /var/run/wlan_green ;; stop) if [ test -f /var/run/wlan_green ]; then kill `cat /var/run/wlan_green` rm /var/run/wlan_green fi ;; restart) ${0} stop sleep 1 ${0} start ;; status) statusproc wpa_supplicant ;; *) echo "Usage: ${0} {start|stop|restart|status}" exit 1 ;; esac # End $rc_base/init.d/wlan_green EOF chmod 754 /etc/init.d/wlan_green
Avec Ipfire, il est important de prendre en compte une subtilité sur la numérotation des liens symboliques. En effet, lors du démarrage d'Ipfire, le script initialisant la connexion Ethernet "/etc/init.d/networking/red" recherche le processus wpa_supplicant. S'il trouve un pid, le script shunt dhcpcd, voir code source ci-dessous.
# Extrait du fichier /etc/init.d/networking/red elif [ "${TYPE}" == "DHCP" ]; then # Add firewall rules to allow comunication with the dhcp server on red. iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT echo -n "${DEVICE}" > /var/ipfire/red/iface # Check if the wlan-client is used on red. # To determine this we check if a wpa_supplicant is running. pid="$(pidof wpa_supplicant)" if [ -z "${pid}" ]; then # No wpa_supplicant is running. So it's save to start dhcpcd. dhcpcd_start "${DEVICE}" fi ## Create & Enable vnstat /usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1 # fin de l'extrait
Il est important de lancer le script wlan_green après le script /etc/init.d/network sinon ipfire ne découvrira pas ses paramètres réseaux.
ln -s /etc/init.d/wlan_green /etc/rc.d/rc3.d/S21wlan_green ln -s /etc/init.d/wlan_green /etc/rc.d/rc0.d/K79wlan_green ln -s /etc/init.d/wlan_green /etc/rc.d/rc6.d/K79wlan_green
Même en lançant la connexion wifi avant le script /etc/init.d/network, il est possible de forcer l'initialisation DHCP de red.
dhcpcd red0
Comments
So empty here ... leave a comment!