Page 1 of 1
Check UDP ports?
Posted: Wed May 30, 2018 11:17 am
by riahc3
What is the easiest way to check UDP ports if they are open?
The plug in Nagios expects me to send and way for a expected string. Dont quite understand stand.
Id also avoid using external tools like nmap and such and would perfer to use what is built in the OS (CentO)
Re: Check UDP ports?
Posted: Wed May 30, 2018 12:14 pm
by mcapra
check_udp is the easiest plugin for this. What you should send/receive depends on the process bound to the port. You could experiment with this plugin using the
-v or
--verbose flags to see what is returned when providing various send/expect strings. Or ask the vendor/developer for valid request/response pairs.
Send it total junk with whatever for the expect value and see what gets returned. Use that to inform your expect string.
More info:
https://support.nagios.com/forum/viewto ... 00#p251500
Re: Check UDP ports?
Posted: Wed May 30, 2018 3:14 pm
by scottwilkerson
check_udp comes with the standard nagios-plugins package most people install as part of their nagios setup.
Re: Check UDP ports?
Posted: Thu May 31, 2018 2:17 am
by riahc3
mcapra wrote:check_udp is the easiest plugin for this. What you should send/receive depends on the process bound to the port. You could experiment with this plugin using the
-v or
--verbose flags to see what is returned when providing various send/expect strings. Or ask the vendor/developer for valid request/response pairs.
Send it total junk with whatever for the expect value and see what gets returned. Use that to inform your expect string.
More info:
https://support.nagios.com/forum/viewto ... 00#p251500
Is there some kind of list Nagios provides? It is impossible to know what every single vendor and application expects to be sent and as a reply...
I personally find it stupid; There must be some implementation (NRPE or SNMP) that can correctly detect if a UDP port is open....
Re: Check UDP ports?
Posted: Thu May 31, 2018 8:48 am
by mcapra
Validating a request/response pair is the only way you could feasibly know whether or not a UDP port is actually capable of receiving traffic. This is a limitation of UDP as it is a connectionless protocol. Simply checking if routing rules allow for access of a port is no guarantee that traffic can actually reach the port and transmit data, only that the route itself is unrestricted. Even if the port is in a "listening" state as far as the host OS is concerned, this is still not a guarantee that traffic can be transmitted. Given all that, it's not entirely surprising to me that I've been unable to find community plugins supporting this particular use case.
You're quite right that it is practically impossible to know what every single vendor/application will return for any given protocol. That's why I suggested a bit of simple investigation.
If you're looking for something that can detect, on a host system, if a given port is in a "listening" state, I'd recommend combining this plugin with an agent like NRPE or
NCPA:
https://github.com/karatalapu80/Nagios- ... enPorts.py
Which leverages
netstat. You may need to install a system package (most commonly
net-tools) if the host system does not have the
netstat binary available. Though if you're just curious on whether or not the port's parent process is running, there's always
check_procs which would accomplish roughly the same thing in most cases.
Here is another non-Python option that could be run on the host system via NRPE which leverages
netstat,
sed, and
grep:
https://exchange.nagios.org/directory/P ... sh/details
Re: Check UDP ports?
Posted: Thu May 31, 2018 9:05 am
by scottwilkerson
Also, there is no way to know in advance what to expect as a response because what the response is depends on the application that is listening on the UDP port.
This can be any application and as such Nagios, or anything else cannot know in advance what an appropriate response is.