0

The Raspberry Pi Zero W is running Raspbian Jessie Lite headless.

After I turn on my Raspberry Pi Zero W if I disconnect the access point it was connecting to, it'll show an IP of 169.254.x.x. I tried this once yesterday and another time today. I don't know if it's just not connecting to another access point or it's only a coincidence that makes me think it's related to the access point dropping off.

Since it's headless, the only way I know it's getting that IP is through my UniFi Controller which lists out all clients on the network. It should be getting a statically assigned IP address from the router. I'm also unable to SSH or ping it at the 169.254.x.x address.

The only workaround I have is power-cycling.

What can I do to stop this from happening?

2
  • 169.254.x.x is a Link-local address
    – Milliways
    Commented Jul 1, 2017 at 22:55
  • Correct. So that usually only happens when it can't get an IP over DHCP. I do not believe that's the case in this instance because it has a reserved IP on the router which gets statically assigned. Also, my hardwired Raspberry Pi 3 does not experience the same issue. I haven't tested it against Wi-Fi yet.
    – Sawtaytoes
    Commented Jul 1, 2017 at 22:59

1 Answer 1

0

The issue is the standard Wi-Fi connection only happens at startup. Once that occurs, you need to have something running in the background to check if you're still connected and reconnect you if you're not.

There's a great solution here pointing at a script you run in crontab: https://raw.githubusercontent.com/dweeber/WiFi_Check/master/WiFi_Check

It will check if you're connected to Wi-Fi, and if not, reconnect you. It handles the case where you might have 2 running at the same time by creating a lockfile every time it's run.

The simplest solution is to run a script like this which has a 60 second timer and reconnects you each time if ifconfig doesn't say you're connected to Wi-Fi.

#!/bin/bash

while true ; do
   if ifconfig wlan0 | grep -q "inet addr:" ; then
      sleep 60
   else
      echo "Network connection down! Attempting reconnection."
      ifup --force wlan0
      sleep 10
   fi
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.