Skip to content

Instantly share code, notes, and snippets.

@rsperl
Last active July 25, 2022 16:16
Show Gist options
  • Save rsperl/5f10d524f7b6f670db9fb8bdee9e81d4 to your computer and use it in GitHub Desktop.
Save rsperl/5f10d524f7b6f670db9fb8bdee9e81d4 to your computer and use it in GitHub Desktop.
use netcat to see if a remote UDP port is open #networking #shell #snippet
#!/bin/sh
# check if a upd port is open with netcat
nc -v -u -z -w 3 localhost 5000
# send a test packet
# -n - Tells the echo command to not output the trailing newline.
# -4u Use IPV4 addresses only. Use UDP instead of TCP.
# -w1 Silently close the session after 1 second of idle time. That way, we’re not stuck waiting for more data.
echo -n “foo” | nc -4u -w1 <host> <udp port>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment