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, it connects to and gets 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 to, 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.

  • I should also mention here that the network is unreachable by ping in this condition.
    – LavaHot
    Commented Jun 9, 2015 at 2:42

1 Answer 1


Actually a funny story. We use a TP-Link Wifi Extender and it seems that the default subnet is I strongly suggest people be careful and aware of the trouble these things might cause, especially during debug.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .