1
0
Fork 0
scripts-admin-quickndirty-p.../mini-ap-wifi/launch-wifi-ap.sh

28 lines
533 B
Bash
Executable file

#!/bin/sh
ifconfig wlan0 192.168.10.2 netmask 255.255.255.0
echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j MASQUERADE
udhcpd -f -S launch-wifi-ap-udhcpd.conf &
DHCPD_PID="$!"
hostapd ~/launch-wifi-ap-hostapd.conf &
HOSTAPD_PID="$!"
sleep 5
echo
echo
echo "Appuyer sur Entree pour quitter..."
read LINE
kill -2 "$DHCPD_PID"
kill -2 "$HOSTAPD_PID"
# Nettoyage
iptables -t nat -D POSTROUTING -s 192.168.10.0/24 -j MASQUERADE
echo 0 >/proc/sys/net/ipv4/ip_forward
ifconfig wlan0 down