yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 8:36 am

I have come across a strange problem and I don't know how to debug it.

I have my Raspberry Pi 4 (latest OS image) set up with these network settings:

/etc/dhcpcd.conf

Code: Select all

interface eth0
    static ip_address=192.168.0.10/24
    static routers=192.168.0.1
    static domain_name_servers=192.168.0.1

interface wlan0
    static ip_address=192.168.0.11/24
    static routers=192.168.0.1
    static domain_name_servers=192.168.0.1
Everything works fine and I get the correct IP addresses assigned for each interface.

If I shut down the Pi with

Code: Select all

sudo shutdown -h now
and later restart the Pi, again, everything is normal.

The problem occurs when I reboot. The Pi fails to find the wired IP address and the boot process hangs. If I unplug the network cable and immediately plug it back in then the boot process continues and everything is normal again. Obviously unplugging/re-plugging the cable is not a great solution, especially when the Pi is run headless in a remote location.

Something is obviously different in the

Code: Select all

sudo shutdown -r now
,

Code: Select all

sudo reboot
and

Code: Select all

sudo shutdown -h now
processes.

How do I go about debugging this?

Tell me if there is any commands you would like me to run.

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 9:00 am

It sounds to me like your pi is waiting for some response from your router, I would suggest power cycling your router and the pi to see if that fixes the problem.

note your static IP addresses should also be outside the address range of the DHCP server in your router.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 9:43 am

pcmanbob wrote:
Tue Jul 09, 2019 9:00 am
It sounds to me like your pi is waiting for some response from your router, I would suggest power cycling your router and the pi to see if that fixes the problem.

note your static IP addresses should also be outside the address range of the DHCP server in your router.
I have confirmed my static IP addresses are outside the DHCP address range (192.168.0.200 to 230) on my router.

I have tried power cycling my router... no difference. The Pi works as expected if it is shutdown and then restarted. The problem comes if I just reboot instead. No other devices on my network have any problem getting DHCP addresses or having them set statically.

epoch1970
Posts: 3655
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 10:02 am

yanewby wrote:
Tue Jul 09, 2019 8:36 am
Tell me if there is any commands you would like me to run.
Reboot, don't touch anything, open a console, run "ip -d link show eth0" and post the result here.
This will print your MAC address starting with "b8:27:eb", you can change the last 3 bytes if you prefer.

That should say if the hardware interface is not seen as up or if the OS is confused.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 10:08 am

epoch1970 wrote:
Tue Jul 09, 2019 10:02 am
yanewby wrote:
Tue Jul 09, 2019 8:36 am
Tell me if there is any commands you would like me to run.
Reboot, don't touch anything, open a console, run "ip -d link show eth0" and post the result here.
This will print your MAC address starting with "b8:27:eb", you can change the last 3 bytes if you prefer.

That should say if the hardware interface is not seen as up or if the OS is confused.
The result of that command after shutting down and then powering up again is:

Code: Select all

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether dc:a6:32:04:a8:d7 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 1500 addrgenmode none numtxqueues 5 numrxqueues 5 gso_max_size 65536 gso_max_segs 65535 
I cannot run the command after a reboot as I am running headless (do not have a new type HDMI cable).

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 10:10 am

epoch1970 wrote:
Tue Jul 09, 2019 10:02 am

Reboot, don't touch anything, open a console, run "ip -d link show eth0" and post the result here.
This will print your MAC address starting with "b8:27:eb", you can change the last 3 bytes if you prefer.

That should say if the hardware interface is not seen as up or if the OS is confused.

Going to be difficult to do that as the OP say boot process hangs..
The Pi fails to find the wired IP address and the boot process hangs. If I unplug the network cable and immediately plug it back in then the boot process continues and everything is normal again

which is why I did not ask them to try running any commands, what we need to know is if the pi is just left will the boot process continue after some time , this could be several minutes.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 10:22 am

which is why I did not ask them to try running any commands, what we need to know is if the pi is just left will the boot process continue after some time , this could be several minutes.
I have tried leaving the pi on and coming back several hours later... still the only way to get back on the network is to unplug the network cable and then immediately plug it back in.

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 10:42 am

So we need to figure out were exactly your pi is hanging , which version of the OS are you using with GUI/desktop or lite ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:00 am

pcmanbob wrote:
Tue Jul 09, 2019 10:42 am
So we need to figure out were exactly your pi is hanging , which version of the OS are you using with GUI/desktop or lite ?
Raspbian Buster Lite.

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:04 am

Then try a reboot and once it hangs take a good quality picture , so we can read what's on the screen and upload it to an image sharing site
( imgur.com for example ) and post a link to it here so we can see what's happening.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
DougieLawson
Posts: 36098
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:08 am

yanewby wrote:
Tue Jul 09, 2019 8:36 am

The problem occurs when I reboot. The Pi fails to find the wired IP address and the boot process hangs. If I unplug the network cable and immediately plug it back in then the boot process continues and everything is normal again. Obviously unplugging/re-plugging the cable is not a great solution, especially when the Pi is run headless in a remote location.
What's in /boot/cmdline.txt ?
Do you have an ip=192.168.xxx.xxx phrase in there?

If you do then you WILL get a 120second hang during boot when the eth0 interface is not connected.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

epoch1970
Posts: 3655
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:14 am

My bad.
Maybe the OP has set "wait for networking" (?) in raspi-config and that causes a seemingly interminable delay?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:22 am

pcmanbob wrote:
Tue Jul 09, 2019 11:04 am
Then try a reboot and once it hangs take a good quality picture , so we can read what's on the screen and upload it to an image sharing site
( imgur.com for example ) and post a link to it here so we can see what's happening.
Unfortunately I am running headless and don't have one of those mini HDMI cables that the Pi4 takes (yet).

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:22 am

epoch1970 wrote:
Tue Jul 09, 2019 11:14 am
My bad.
Maybe the OP has set "wait for networking" (?) in raspi-config and that causes a seemingly interminable delay?
I have used raspi-config to set waiting for network to "no".

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:24 am

DougieLawson wrote:
Tue Jul 09, 2019 11:08 am
yanewby wrote:
Tue Jul 09, 2019 8:36 am

The problem occurs when I reboot. The Pi fails to find the wired IP address and the boot process hangs. If I unplug the network cable and immediately plug it back in then the boot process continues and everything is normal again. Obviously unplugging/re-plugging the cable is not a great solution, especially when the Pi is run headless in a remote location.
What's in /boot/cmdline.txt ?
Do you have an ip=192.168.xxx.xxx phrase in there?

If you do then you WILL get a 120second hang during boot when the eth0 interface is not connected.
I have no lines containing "ip=" in /boot/config.txt. Should there be one?

epoch1970
Posts: 3655
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:26 am

yanewby wrote:
Tue Jul 09, 2019 11:24 am
I have no lines containing "ip=" in /boot/config.txt. Should there be one?
No. Only for network/NFS booting.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 36098
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:28 am

epoch1970 wrote:
Tue Jul 09, 2019 11:26 am
yanewby wrote:
Tue Jul 09, 2019 11:24 am
I have no lines containing "ip=" in /boot/config.txt. Should there be one?
No. Only for network/NFS booting.
There was a habit of folks using that to get a fixed IP address. Not just for NFS.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:30 am

I have just tried making the wifi connect first by adding metric 300 to the eth0 section in dhcpcd.conf and metric 200 to the wlan0 section.

I have rebooted three times in a row but now the wifi is the default internet route which isn't ideal.

If I swap the metrics around (eth0 to boot first) then the boot fails again.

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:34 am

As we don't have anyway to see what the pi is doing, lets try and eliminate the router as the cause of the problem.

So using a spare SD card flash a fresh copy of raspbian lite on it , then once its booted for the first time , set a static IP on the eth0 only , and do not make any wifi connection at all, then try the shutdown and reboot cycles and see if that works.

edit
missed your last post but I would still try the above just to see if it works.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:42 am

pcmanbob wrote:
Tue Jul 09, 2019 11:34 am
As we don't have anyway to see what the pi is doing, lets try and eliminate the router as the cause of the problem.

So using a spare SD card flash a fresh copy of raspbian lite on it , then once its booted for the first time , set a static IP on the eth0 only , and do not make any wifi connection at all, then try the shutdown and reboot cycles and see if that works.

edit
missed your last post but I would still try the above just to see if it works.
OK, I have just burned the Lite zip again using Etcher. Added only the eth0 section into dhcpcd.conf.

First reboot was a success. Second and third failed (had to use the unplug/plug network cable trick).

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:48 am

So I am thinking this is probably a network problem rather than a pi problem , I don't see it as a corrupt OS as the reboot worked first time.

so is this a domestic broadband router or a work/university network ?
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:54 am

pcmanbob wrote:
Tue Jul 09, 2019 11:48 am
So I am thinking this is probably a network problem rather than a pi problem , I don't see it as a corrupt OS as the reboot worked first time.

so is this a domestic broadband router or a work/university network ?
A domestic broadband router with OpenWRT installed (Linksys WRT-1900ACS). The strange thing is this Pi is the only one experiencing this problem and I must have 10+ other devices all on the same network without any issues at all.

pcmanbob
Posts: 6906
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 11:59 am

Then I suggest you look at the router logs to see it there is anything in there that might provide a clue as to the problem ,

failing that have the router web page open on the connected devices while you are doing the reboot , refreshing the web page as fast as possible to see it the router actually sees the pi drop the connection.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 12:01 pm

I have just tried re-directing the hostname -I command in rc.local to a file so that this could be read after unplugging/plugging. It was blank.

I tried adding an ifconfig in there as well but this suggested to me there was no network connection:

Code: Select all

eth0: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether dc:a6:32:04:a8:d7  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
I guess rc.local gets run too early in the boot?

yanewby
Posts: 58
Joined: Sun Nov 18, 2012 12:22 pm

Re: Network fails after rebooting but fine after shutting down

Tue Jul 09, 2019 12:04 pm

pcmanbob wrote:
Tue Jul 09, 2019 11:59 am
Then I suggest you look at the router logs to see it there is anything in there that might provide a clue as to the problem ,

failing that have the router web page open on the connected devices while you are doing the reboot , refreshing the web page as fast as possible to see it the router actually sees the pi drop the connection.
I couldn't see anything in the logs (only the wifi connecting from previously). Similar negative result from the connected devices idea.

I hope to get another Pi4 in the next week or two. Maybe I will have more success with that one.

I don't understand why altering the metrics so that wifi is the default route allows the rebooting.

Return to “Troubleshooting”