Make sure you have the Debian version of wpa_supplicant
installed (specifically, you need the wpa_action
script with it's
dependencies which can be found here). If you're using
Raspbian, you have this already. If you're using something like Arch
or Buildroot, you'll need to install those scripts manually.
Set up dnsmasq to run it's DHCP server all the time (there is no real need to disable it when it's not being used). It needs to run at startup, and use a dnsmasq.conf
like this:
# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.
port=0
interface=wlan0
dhcp-authoritative
dhcp-leasefile=/tmp/dhcp.leases
dhcp-range=10.0.0.2,10.0.0.10,24h
#subnet mask
dhcp-option=1,255.0.0.0
# Do not send gateway to client
dhcp-option=3
# Disable DNS
dhcp-option=6
- Make your
/etc/wpa_supplicant/wpa_supplicant.conf
something like this:
ctrl_interface=DIR=/var/run/wpa_supplicant
network={
ssid="yourSSID"
key_mgmt=WPA-PSK
psk="yourpasscode"
priority=1
id_str="dhcp_client"
}
network={
ssid="Hotspot"
mode=2
key_mgmt=WPA-PSK
psk="password"
frequency=2437
id_str="dhcp_server"
}
- And make your
/etc/network/interfaces
something like this:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet manual
wpa-driver nl80211
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface dhcp_server inet static
address 10.0.0.1
netmask 255.0.0.0
iface dhcp_client inet dhcp