In classic .NET Framework applications, we have used System.Net.NetworkInformation.Ping class to Ping a host address. This API is not included by default in .NET Core, even in version 2.0. Here is how to do it in a .NET Core way.

First, we need to reference a package System.Net.Ping

Install-Package System.Net.Ping

This will give us the same API set as .NET Framework.

Then, in your .NET Core code, you can use the Ping class in the exact same way as .NET Framework app. In this example, i am using a .NET Core 2.0 console app:

static void Main(string[] args)
{
    string targetHost = "bing.com";
    string data = "a quick brown fox jumped over the lazy dog";

    Ping pingSender = new Ping();
    PingOptions options = new PingOptions
    {
        DontFragment = true
    };
    
    byte[] buffer = Encoding.ASCII.GetBytes(data);
    int timeout = 1024;

    Console.WriteLine($"Pinging {targetHost}");
    PingReply reply = pingSender.Send(targetHost, timeout, buffer, options);
    if (reply.Status == IPStatus.Success)
    {
        Console.WriteLine($"Address: {reply.Address}");
        Console.WriteLine($"RoundTrip time: {reply.RoundtripTime}");
        Console.WriteLine($"Time to live: {reply.Options.Ttl}");
        Console.WriteLine($"Don't fragment: {reply.Options.DontFragment}");
        Console.WriteLine($"Buffer size: {reply.Buffer.Length}");
    }
    else
    {
        Console.WriteLine(reply.Status);
    }
}

But please keep in mind, you may see the .NET Framework version of this example on MSDN with timeout value set to 120, this will get ping falied very easily, I changed this value to 1024, then this sample can run successfully. This is not a difference between .NET Framework and .NET Core, it will also fail with value of 120 on .NET Framework app.

Another thing is that UWP 6.0.1 is using .NET Core 2.0, but Ping is not currently supportted. If you try this in an UWP App, it will blow up sky high: