0

I have a Raspberry Pi Zero W project that needs a network connection for some of its functionality. The device normally does not have a keyboard and display attached, as it's operated by hardware switches and sensors. Most of the updating/debugging is done via an ssh connection. So it's a big pain if the WiFi connection goes bad.

What could be the possible explanation for the following WiFi connection problem:

The device boots up and the boot log kind of confirms that connecting to the network is successful:

[  OK  ] Started WPA supplicant
[  OK  ] Reached target Network

Running $ ifconfig wlan0 shows that it has received its assigned IP address 192.168.x.x. But it can neither be pinged from another PC in the network nor the router address 192.168.1.1 can be pinged from the Pi. Actually, when trying to ping the Pi from another PC, instead of "Destination Host Unreachable" it just gets stuck, ping does not generate new retries.

Running $ sudo iwlist wlan0 scan gives a list of available networks, so apparently there is no problem with the antenna. Running $ sudo wpa_cli -i wlan0 reconfigure does not fix the situation.

And then, after a while, spontaneously, it can suddenly reconnect and everything is fine until it's not again.

Update with Info from comments:
I use just a plain raspbian default. When the device spontaneously reconnects, there are no connection problems, both from Pi and to Pi.

There are two wifi network configurations, one for the router, another for my mobile hotspot. But the hotspot is not active, and the IP address that I get with ifconfig wlan0 is the one that is properly assigned by the router's DHCP. Ok, I don't know, maybe it's not freshly received, maybe it's remembering the last address somehow.

  • Are you sure the AP Isolation of your router is disabled? – M. Rostami Jan 1 at 17:11
  • @M.Rostami that is definately not the issue. AP isolation is not enabled, and when the device has reconnected to the network, there is no issues whatsoever. – Passiday Jan 1 at 20:00
  • Actually, when trying to ping the Pi from another PC, instead of "Destination Host Unreachable" it just gets stuck have you a firewall on the pinged host ? – Ephemeral Jan 1 at 20:24
  • @Ephemeral no, just a plain raspbian default. When the device spontaneously reconnects, there are no connection problems, both from Pi and to Pi. – Passiday Jan 1 at 22:14
  • 1
    Check it out. raspberrypi.stackexchange.com/a/57278/44221 – M. Rostami Jan 3 at 0:43
0

I had a somewhat similar issue. I solved by setting a static address via dhcpcd.conf for the Pi Zero since Raspian uses dhcpcd to manage network interfaces by default.

Pick and assign a static IP address for the Pi by editing the /etc/dhcpcd.conf file. It would look something like this:

interface wlan0
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
static ip_address=192.168.1.255/24 # Pi Zero selected address
static routers=192.168.1.1

I would also reserve the static address that you pick for the Pi from within the router (so it's not re-assigned to another device). Alternatively you can also set an IP range from the router to prevent it from ever assigning the address for the Pi.

More info about dhcpd static config here

  • 1
    Why the problem solved by this procedure? Sound weird. – M. Rostami Jan 7 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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