Last active
July 25, 2022 16:16
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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