hashicorp / consul-esm

External service monitoring for Consul
Mozilla Public License 2.0
262 stars 41 forks source link

Pinging over "UDP". What does it mean? #241

Open monegim opened 9 months ago

monegim commented 9 months ago

Hi,

I tried to read the source code. however, I could not understand what it means by ping type. Is it using "UDP" over ICMP or as a ping protocol? Should there not be a port for pinging over "UDP" on node definition?

In network view, should the firewall on the host allow for "ICMP" or "UDP"?

blake commented 8 months ago

Consul ESM defaults to using udp as the default ping_type.

The ping functionality is provided by https://github.com/go-ping/ping. The readme for that project has a short section that explains why the library defaults to using "UDP" pings on Linux instead of ICMP. (See https://github.com/go-ping/ping#linux.)

Basically, Linux allows for unprivileged users to send ICMP echo requests and receive the corresponding replies if they are sent over a UDP socket. Creating UDP sockets on Linux does not require elevated privileges whereas creating a raw socket to send ICMP does require special privileges. (Such would be the case if the ping_type was set to icmp.)

The following resources explain this in a bit more detail.

I hope this helps.