Alternatively, you can create a mini-service which restarts the wlan0, making sure it starts at boot before hostapd and isc-dhcp-server.
Create the new script /etc/init.d/wlan0-restart
sudo vi /etc/init.d/wlan0-restart
with the following content:
#!/bin/sh # # ### BEGIN INIT INFO # Provides: wlan0-restart # Required-Start: $network # Required-Stop: $network # Should-Start: # Should-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Restarts wlan0 interface # Description: Restarts wlan0 interface to fix problem with static address in WiFi AP # X-Start-Before: hostapd isc-dhcp-server ### END INIT INFO PATH=/sbin:/usr/sbin:$PATH do_start() { ifdown wlan0 ifup wlan0 } case "$1" in start) do_start ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) ;; status) ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac exit 0
Then execute the following commands:
sudo chmod 755 /etc/init.d/wlan0-restart sudo update-rc.d –f hostapd remove sudo update-rc.d –f isc-dhcp-server remove sudo update-rc.d wlan0-restart defaults sudo update-rc.d hostapd defaults sudo update-rc.d isc-dhcp-server defaults
Reboot and check that wlan0 has its static IP address and that isc-dhcpd-server is running:
pi@raspberrypi:~$ ifconfig wlan0 wlan0 Link encap:Ethernet HWaddr e8:de:27:07:92:6a inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) pi@raspberrypi:~$ pgrep -l dhcpd 2315 dhcpd