Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to properly ping a hostname that resolves to multiple IP addresses?

I want to ensure network resources are available.

I know how to ping a single IP address and most examples show how to get an IP from a hostname to then ping it.

But as a hostname can resolve to multiple IP addresses as returned by IPAddress[] System.Networking.Dns.GetHostAddress(string), how do I do that properly?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Should I ping all of them? Is it sufficient if any of them is available?

>Solution :

That depends on what you want to verify. Multiple IPs means that the services are available from different physical servers (possibly in different parts of the world). A typical application would just take any of them, which then causes an implicit load balancing between the servers.

So if you want to check whether a particular service is reachable, you can just ping any of the addresses. Particularly if these are your own services you might want to ping all of them to make sure your distributed servers are all working.

In either case, you should be aware that pinging is a very low-level method of checking service availability. Just because a server responds to a ping request doesn’t say anything about the availability of its higher-level services (e.g. http, e-mail, whatever). Even the opposite is true: The server might work just fine but have ping blocked by firewall rules.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading