I'm trying to set up a script so that I can switch between wlan0 being an AP and being a client at certain times, but I hit a snag. Hostapd and dnsmasq both start up fine and appear to work normally, but when I stop them and try to get the interface to work as a client once more by doing dhclient wlan0
the IP assigned is incorrect. Where the subnet I'm connected to is 192.168.10.0, it connects to 192.168.0.0 and gets 192.168.0.105 every time. Even when I release the lease with dhclient -r wlan0
, when I empty dhclinet.wlan0.leases, and when I change the physical dongle to a different one of the same model.
My dnsmasq.conf sets the dhcp range to be 192.168.1.50 to 192.168.1.55, so I don't think I'm getting DHCP from my own dnsmasq (at least not obviously).
If I do iwconfig wlan0
, it reports that it is connected to the SSID of the AP and seems normal.
If I get dnsmasq and hostapd to not run at start time, everything seems fine and wlan0 can get an IP normally. After I start and stop hostapd and dnsmasq I experience the behavior above.