2

Upon reboot and login, I want to check to see if a remote computer (10.1.0.53) is listening for UDP on port 2222. I have tried adding the following line to ~/.bashrc (later, I tried ~/.profile, with the same result):

nc -z -u -v 10.1.0.53 2222

Upon reboot, I get the message:

nc: connect to 10.1.0.53 port 2222 (UDP) failed: Network is unreachable

If I immediately try source .bashrc at the prompt, it succeeds and outputs:

Connection to 10.1.0.53 2222 port [udp/*] succeeded!

How do I make netcat wait until the network is reachable? (10.1.0.53 is listening the entire time).

2

Assuming you are using Raspbian, you can use raspi-config to delay boot until the network is up.

start raspi-config with the following:

sudo raspi-config

then select option 4 Wait for network at boot

then select Slow Wait for network connection before completing boot

click Ok

Then Finish

Finally reboot.

  • 1
    Is it possible to edit a file by hand instead of running raspi-config? – Jason Floyd Apr 11 '18 at 23:42
  • yes, check the raspi-config source that is all it is doing. though raspi-config is easier and far less prone to error. – Steve Robillard Apr 11 '18 at 23:44
  • What is this option doing under the hood? – ManuelSchneid3r Apr 12 '18 at 14:19
  • Scratch user here, I can't seem to find the option on raspi-config - but if you click on the Raspberry Pi symbol on the taskbar (application menu) and then 'Preferences' -> 'Raspberry Pi Configuration' you can see the option 'wait for network' raspberrypi.org/blog/latest-raspbian-update – Dante Sep 23 '18 at 15:13
  • 1
    @JasonFloyd The files raspi-config modifies are shown in this part of the code: github.com/RPi-Distro/raspi-config/blob/…. Alternatively, you can avoid modifying files manually or having to interact with raspi-config by running raspi-config nonint do_boot_wait 0 – davidjb Apr 18 at 12:46

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.