It is occasionally necessary to identify the underlying IP address for a domain name from within the context of our software. For that, .NET Core provides the static Dns class as part of the System.Net namespace. With the Dns class, we can access directory information as returned by the nearest downstream name server capable of resolving the given name. We can request an instance of the IPHostEntry class, containing all of the relevant directory information of a DNS entry, or simply an array of IP addresses registered to resolve requests against the domain name.
To see this in action, simply invoke any of the methods exposed by the static Dns class in a sample program as follows:
using System;
using System.Net;
using System.Threading;
namespace DnsTest {
public class DnsTestProgram {
static void Main(string[] args) {
var domainEntry = Dns.GetHostEntry...