• DnsClient
  • Readme
  • Api Docs
  • MichaCo.net
This site uses "cookies" - small data files stored locally on your computer - to save information about your preferences when using this site. Learn More.

    Show / Hide Table of Contents

    Class NameServer

    Represents a name server instance used by ILookupClient. Also, comes with some static methods to resolve name servers from the local network configuration.

    Inheritance
    Object
    NameServer
    Implements
    IEquatable<NameServer>
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: DnsClient
    Assembly: DnsClient.dll
    Syntax
    public class NameServer : IEquatable<NameServer>

    Constructors

    | Improve this Doc View Source

    NameServer(IPAddress)

    Initializes a new instance of the NameServer class.

    Declaration
    public NameServer(IPAddress endPoint)
    Parameters
    Type Name Description
    IPAddress endPoint

    The name server endpoint.

    Exceptions
    Type Condition
    ArgumentNullException

    If endPointis null.

    | Improve this Doc View Source

    NameServer(IPAddress, Int32)

    Initializes a new instance of the NameServer class.

    Declaration
    public NameServer(IPAddress endPoint, int port)
    Parameters
    Type Name Description
    IPAddress endPoint

    The name server endpoint.

    Int32 port

    The name server port.

    Exceptions
    Type Condition
    ArgumentNullException

    If endPointis null.

    | Improve this Doc View Source

    NameServer(IPEndPoint)

    Initializes a new instance of the NameServer class.

    Declaration
    public NameServer(IPEndPoint endPoint)
    Parameters
    Type Name Description
    IPEndPoint endPoint

    The name server endpoint.

    Exceptions
    Type Condition
    ArgumentNullException

    If endPointis null.

    Fields

    | Improve this Doc View Source

    Cloudflare

    A public Cloudflare DNS endpoint.

    Declaration
    public static readonly IPEndPoint Cloudflare
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    Cloudflare2

    A public Cloudflare DNS endpoint.

    Declaration
    public static readonly IPEndPoint Cloudflare2
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    Cloudflare2IPv6

    A public Cloudflare DNS IPv6 endpoint.

    Declaration
    public static readonly IPEndPoint Cloudflare2IPv6
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    CloudflareIPv6

    A public Cloudflare DNS IPv6 endpoint.

    Declaration
    public static readonly IPEndPoint CloudflareIPv6
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    DefaultPort

    The default DNS server port.

    Declaration
    public const int DefaultPort = 53
    Field Value
    Type Description
    Int32
    | Improve this Doc View Source

    GooglePublicDns

    The public google DNS IPv4 endpoint.

    Declaration
    public static readonly IPEndPoint GooglePublicDns
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    GooglePublicDns2

    The second public google DNS IPv6 endpoint.

    Declaration
    public static readonly IPEndPoint GooglePublicDns2
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    GooglePublicDns2IPv6

    The second public google DNS IPv6 endpoint.

    Declaration
    public static readonly IPEndPoint GooglePublicDns2IPv6
    Field Value
    Type Description
    IPEndPoint
    | Improve this Doc View Source

    GooglePublicDnsIPv6

    The public google DNS IPv6 endpoint.

    Declaration
    public static readonly IPEndPoint GooglePublicDnsIPv6
    Field Value
    Type Description
    IPEndPoint

    Properties

    | Improve this Doc View Source

    Address

    Gets the string representation of the configured IPAddress.

    Declaration
    public string Address { get; }
    Property Value
    Type Description
    String
    | Improve this Doc View Source

    AddressFamily

    Gets the address family.

    Declaration
    public AddressFamily AddressFamily { get; }
    Property Value
    Type Description
    AddressFamily
    | Improve this Doc View Source

    Port

    Gets the port.

    Declaration
    public int Port { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    SupportedUdpPayloadSize

    Gets the size of the supported UDP payload.

    This value might get updated by ILookupClient by reading the options records returned by a query.

    Declaration
    public int? SupportedUdpPayloadSize { get; }
    Property Value
    Type Description
    Nullable<Int32>

    The size of the supported UDP payload.

    Methods

    | Improve this Doc View Source

    Equals(NameServer)

    Declaration
    public bool Equals(NameServer other)
    Parameters
    Type Name Description
    NameServer other
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    Object.Equals(Object)
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    Object.GetHashCode()
    | Improve this Doc View Source

    ResolveNameServers(Boolean, Boolean)

    Gets a list of name servers by iterating over the available network interfaces.

    If fallbackToGooglePublicDns is enabled, this method will return the google public dns endpoints if no local DNS server was found.

    Declaration
    public static IReadOnlyCollection<NameServer> ResolveNameServers(bool skipIPv6SiteLocal = true, bool fallbackToGooglePublicDns = true)
    Parameters
    Type Name Description
    Boolean skipIPv6SiteLocal

    If set to true local IPv6 sites are skiped.

    Boolean fallbackToGooglePublicDns

    If set to true the public Google DNS servers are returned if no other servers could be found.

    Returns
    Type Description
    IReadOnlyCollection<NameServer>

    The list of name servers.

    | Improve this Doc View Source

    ResolveNameServersNative()

    Using my custom native implementation to support UWP apps and such until GetAllNetworkInterfaces() gets an implementation in netstandard2.1.

    Declaration
    public static IReadOnlyCollection<IPAddress> ResolveNameServersNative()
    Returns
    Type Description
    IReadOnlyCollection<IPAddress>

    The list of name servers.

    Remarks

    DnsClient has been changed in version 1.1.0. It will not invoke this when resolving default DNS servers. It is up to the user to decide what to do based on what platform the code is running on.

    | Improve this Doc View Source

    ToString()

    Returns a String that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    A String that represents this instance.

    Overrides
    Object.ToString()

    Operators

    | Improve this Doc View Source

    Implicit(IPAddress to NameServer)

    Initializes a new instance of the NameServer class from a IPAddress.

    Declaration
    public static implicit operator NameServer(IPAddress address)
    Parameters
    Type Name Description
    IPAddress address

    The address.

    Returns
    Type Description
    NameServer
    | Improve this Doc View Source

    Implicit(IPEndPoint to NameServer)

    Initializes a new instance of the NameServer class from a DnsClient.NameServer.IPEndPoint.

    Declaration
    public static implicit operator NameServer(IPEndPoint endPoint)
    Parameters
    Type Name Description
    IPEndPoint endPoint

    The endpoint.

    Returns
    Type Description
    NameServer

    Implements

    IEquatable<T>
    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net