How to do UDP Ping with Linux

Background

UDP Ping is really useful especially to see if SNMP is running. The syntax for UDP checking commands is a bit obscure so we’ve listed a few variants.

How to do UDP Ping with Linux
How to do UDP Ping with Linux

NMAP

SNMP running on port 161 UDP, closed:

➜ ~ sudo nmap -sU -p 161 server1.example.com
Starting Nmap 7.93 ( https://nmap.org ) at 2025-06-11 14:36 SAST
Nmap scan report for server1.example.com (a.b.c.d)
Host is up (0.000099s latency).

PORT    STATE        SERVICE
161/udp closed       snmp

SNMP running on port 161 UDP, open but filtered:

➜ ~ sudo nmap -sU -p 161 server2.example.com
Starting Nmap 7.80 ( https://nmap.org ) at 2022-02-09 11:01 SAST
Nmap scan report for server2.example.com (a.b.c.d)
Host is up (0.022s latency).

PORT    STATE         SERVICE
161/udp open|filtered snmp

SNMP running on port 161 UDP,  open:

➜ ~ sudo nmap -sU -p 161 server3.example.com
Starting Nmap 7.80 ( https://nmap.org ) at 2022-02-09 11:01 SAST
Nmap scan report for server3.example.com (a.b.c.d)
Host is up (0.023s latency).

PORT    STATE         SERVICE
161/udp open          snmp

NC

nc is also known as nmap-ncat. Here is the command syntax to test if an UDP port is listening with nc. Be sure to use the v verbose switch to get the full story.

nc -zvu serverxyz.abc.com 161
Connection to serverxyz.abc.host 161 port [udp/snmp] succeeded!

Or try this (not working version – see 0 bytes received):

[root@872397-db1 ~]# nc -zvu 127.0.0.1 161
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Connected to 127.0.0.1:161.
Ncat: UDP packet sent successfully
Ncat: 1 bytes sent, 0 bytes received in 2.01 seconds.

Alternatives

sudo nmap -sU -p port target
nping –udp -p port target
hping3 -S –udp -p port target

See also

References

Tags

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *