5

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).

Hyperfine
  • 63
  • 1
  • 1
  • 4

1 Answers1

5

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.

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110