john2000
Posts: 7
Joined: Thu Nov 21, 2019 11:35 pm

Pi Zero W unreachable over network after a few hours

Thu Dec 12, 2019 9:08 pm

EDIT: The pi is running this from the output of hostnamectl:

Operating System: Raspbian GNU/Linux 9 (stretch)
Kernel: Linux 4.19.66+

I have been running Owncloud on a pi zero W with a static ip for a few months with no problems. Recently while getting support from my ISP, the tech support reverted some settings including the SSID and password of the 2.4 GHz wifi on my modem router. I don't know what else was reset in the router and the issue wasn't the router, just bad wireless drivers on my laptop. I went into my pi and updated the wifi information, and it connects fine at first.

A while after connecting to the router, the pi becomes unreachable on the local network by other devices, but it can connect to the internet and ping other devices on the network. Also if I use a tool built into my router to ping the pi it does not work. My desktop and laptop have Owncloud client software to keep some files in sync. The Owncloud client software reports "No connection to (my shared folder name) at (my url). Connection timed out." This happens both on my local network with my desktop and laptop, and on my laptop when I am away from my home network.

Things that will "wake up" the pi and cause the desktop clients to see it again:
-Logging in to the pi's web interface
-Pinging another device on the network from the pi
-Restarting the wlan0 interface with "sudo ifconfig wlan0 down" then "sudo ifconfig wlan0 up"
-Rebooting

Note that the web interface is always available, the pi becomes undiscoverable at random times, and the first two of the above solutions do not always work. Also the client software cannot access

I had this problem months ago when I first got the system running, but I cannot remember what I did to fix it. I have researched the pi zero w wifi power saving mode. I disabled power management for wlan0 so that iwconfig reports "Power Management:off" among other output. I also added "iwconfig wlan0 power off" to /etc/rc.local before the "exit 0" at the bottom of the file to turn off power management every reboot.

I would like help figuring out how to keep my pi zero w from becoming undiscoverable on my network.
Last edited by john2000 on Fri Dec 13, 2019 5:43 pm, edited 1 time in total.

ejolson
Posts: 4275
Joined: Tue Mar 18, 2014 11:47 am

Re: Pi Zero W unreachable over network after a few hours

Fri Dec 13, 2019 3:56 pm

john2000 wrote:
Thu Dec 12, 2019 9:08 pm
I have been running Owncloud on a pi zero W with a static ip for a few months with no problems. Recently while getting support from my ISP, the tech support reverted some settings including the SSID and password of the 2.4 GHz wifi on my modem router. I don't know what else was reset in the router and the issue wasn't the router, just bad wireless drivers on my laptop. I went into my pi and updated the wifi information, and it connects fine at first.

A while after connecting to the router, the pi becomes unreachable on the local network by other devices, but it can connect to the internet and ping other devices on the network. Also if I use a tool built into my router to ping the pi it does not work. My desktop and laptop have Owncloud client software to keep some files in sync. The Owncloud client software reports "No connection to (my shared folder name) at (my url). Connection timed out." This happens both on my local network with my desktop and laptop, and on my laptop when I am away from my home network.

Things that will "wake up" the pi and cause the desktop clients to see it again:
-Logging in to the pi's web interface
-Pinging another device on the network from the pi
-Restarting the wlan0 interface with "sudo ifconfig wlan0 down" then "sudo ifconfig wlan0 up"
-Rebooting

Note that the web interface is always available, the pi becomes undiscoverable at random times, and the first two of the above solutions do not always work. Also the client software cannot access

I had this problem months ago when I first got the system running, but I cannot remember what I did to fix it. I have researched the pi zero w wifi power saving mode. I disabled power management for wlan0 so that iwconfig reports "Power Management:off" among other output. I also added "iwconfig wlan0 power off" to /etc/rc.local before the "exit 0" at the bottom of the file to turn off power management every reboot.

I would like help figuring out how to keep my pi zero w from becoming undiscoverable on my network.
I had the same problem but was unable to track what caused it. I think the common belief is that some power saving mode on the radio in the Pi or router is the cause. In my opinion, a security measure that eliminates or filters ARP packets may also cause the Pi to become unreachable. In either case, the root cause seems to be people optimising things according to a single concept of how the computer will be used without the imagination to think a computer might be used in different ways. In particular, the undocumented changes often work well for a laptop but not for a Pi running as a remote network server.

The typical workaround for the problem you mention it to set up a script on the Pi which frequently pings all the important computers on the local subnet. If done often enough this has the benefit of defeating the power saving and security measures, with of course the drawback of defeating the power saving and security measures. It would be nice if someone who has solved this problem in a more intelligent way could explain how.

john2000
Posts: 7
Joined: Thu Nov 21, 2019 11:35 pm

Re: Pi Zero W unreachable over network after a few hours

Fri Dec 13, 2019 6:17 pm

Thanks @ejolson. I am testing the solution to restart the network interface on the pi when wifi is not detected with this tutorial:

https://weworkweplay.com/play/rebooting ... tion-wifi/

I really hate doing it this way because I feel defeated since I remember getting it to work properly before, but I guess being flexible with what solution I use is best.

Another thing to note is that I flashed another pi zero w with buster lite and the same thing happens to it. After a while it is unreachable on the local network. This suggests that the problem is with my router. It could still be a setting common to the pi that disagrees with my router though.

john2000
Posts: 7
Joined: Thu Nov 21, 2019 11:35 pm

Re: Pi Zero W unreachable over network after a few hours

Fri Dec 13, 2019 6:43 pm

I ran /sbin/ifdown 'wlan0' from the script below and got "ifdown: unknown interface wlan0"

ping -c4 192.168.1.1 > /dev/null

if [ $? != 0 ]
then
echo "No network connection, restarting wlan0"
/sbin/ifdown 'wlan0'
sleep 5
/sbin/ifup --force 'wlan0'
fi

I changed the script to this:

echo "Running wifi check"
ping -c4 192.168.0.1 > /dev/null

if [ $? != 0 ]
then
echo "No network connection, restarting wlan0"
sudo ifconfig wlan0 down
sleep 5
sudo ifconfig wlan0 up
fi

based on this thread I found:

https://ubuntuforums.org/showthread.php?t=2344219

john2000
Posts: 7
Joined: Thu Nov 21, 2019 11:35 pm

Re: Pi Zero W unreachable over network after a few hours

Sun Dec 15, 2019 3:47 pm

The solution that pings the router seems to be working. The pi has stayed up for quite a while and I assume it is because of the script. My final version of the script is below. For anyone reading this make sure to follow the tutorial at:

https://weworkweplay.com/play/rebooting ... tion-wifi/

#Write some test to a file to see if the script is working. Disable when done t$
#echo "Running wifi check" >> /home/pi/Desktop/wifiScriptOutput.txt

#Ping the router because everything else has a non static ip.
ping -c4 192.168.0.1 > /dev/null

#If $? (the exit code of the last comand, ping) is not 0, stop and restert
#wlan0
if [ $? != 0 ]
then
echo "No network connection, restarting wlan0"
#Stops wlan0
sudo ifconfig wlan0 down
#Waits 5 seconds
sleep 5
#Starts wlan0
sudo ifconfig wlan0 up
fi

wolf.z
Posts: 131
Joined: Thu Dec 24, 2015 8:34 pm

Re: Pi Zero W unreachable over network after a few hours

Sun Dec 15, 2019 5:43 pm

Check your router's config. With all your Pis using static IP addresses, this might conflict with your router's setting. Configure the IP of your Pi on the router - additionally to the Pis config. Possibly resetting your router has deleted such config. Further, restrict the DHCP address range of your router so as to not conflict with any static IP.

"Things that will "wake up" the pi and cause the desktop clients to see it again:" Might make the router refresh a routing table entry.

PS.: I am using static IPs with all my Pis and sadly never managed to acces them by name. I stay with IP addresses.

john2000
Posts: 7
Joined: Thu Nov 21, 2019 11:35 pm

Re: Pi Zero W unreachable over network after a few hours

Tue Dec 17, 2019 7:12 pm

Thanks @wolf.z. First off, the script did not work. The pi was up for longer but eventually disconnected.

My router's configuration options confuse me. Under the DHCP settings I can select to use a private starting address or a public starting address. I don't know what that means so I go with private which ranges from 192.168.0.2 to 254. I set the number of CPEs to 240. On the static lease page it says the private ip range goes from 192.168.0.2 -- 192.168.0.241. The static lease page also has a table to fill out static ip addresses based on mac addresses. I never used this and never needed to. My pi do have static ips outside of this range.

What is the difference in setting a static ip on a device vs setting it on a router?

Edit: Also what log files should I look at to diagnose wifi connectivity issues?

Return to “Troubleshooting”