• 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 LookupClient

    The LookupClient is the main query class of this library and should be used for any kind of DNS lookup query.

    It implements ILookupClient and IDnsQuery which contains a number of extension methods, too. The extension methods internally all invoke the standard IDnsQuery queries though.

    Inheritance
    Object
    LookupClient
    Implements
    ILookupClient
    IDnsQuery
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: DnsClient
    Assembly: DnsClient.dll
    Syntax
    public class LookupClient : ILookupClient, IDnsQuery
    Examples

    A basic example wihtout specifying any DNS server, which will use the DNS server configured by your local network.

    var client = new LookupClient();
    var result = client.Query("google.com", QueryType.A);
    
    foreach (var aRecord in result.Answers.ARecords())
    {
        Console.WriteLine(aRecord);
    }

    Constructors

    | Improve this Doc View Source

    LookupClient()

    Creates a new instance of LookupClient without specifying any name server. This will implicitly use the name server(s) configured by the local network adapter(s).

    Declaration
    public LookupClient()
    Remarks

    This uses ResolveNameServers(Boolean, Boolean). The resulting list of name servers is highly dependent on the local network configuration and OS.

    Examples

    In the following example, we will create a new LookupClient without explicitly defining any DNS server. This will use the DNS server configured by your local network.

    var client = new LookupClient();
    var result = client.Query("google.com", QueryType.A);
    
    foreach (var aRecord in result.Answers.ARecords())
    {
        Console.WriteLine(aRecord);
    }
    | Improve this Doc View Source

    LookupClient(LookupClientOptions)

    Creates a new instance of LookupClient with custom settings.

    Declaration
    public LookupClient(LookupClientOptions options)
    Parameters
    Type Name Description
    LookupClientOptions options

    The options to use with this LookupClient instance.

    Exceptions
    Type Condition
    ArgumentNullException

    If optionsis null.

    | Improve this Doc View Source

    LookupClient(NameServer[])

    Creates a new instance of LookupClient with default settings and the given name servers.

    Declaration
    public LookupClient(params NameServer[] nameServers)
    Parameters
    Type Name Description
    NameServer[] nameServers

    The NameServer(s) to be used by this LookupClient instance.

    Exceptions
    Type Condition
    ArgumentNullException

    If nameServersis null.

    | Improve this Doc View Source

    LookupClient(IPAddress, Int32)

    Create a new instance of LookupClient with default settings and one DNS server defined by address and port.

    Declaration
    public LookupClient(IPAddress address, int port)
    Parameters
    Type Name Description
    IPAddress address

    The IPAddress of the DNS server.

    Int32 port

    The port of the DNS server.

    Examples

    Connecting to one specific DNS server which does not run on the default port 53:

    var client = new LookupClient(IPAddress.Parse("127.0.0.1"), 8600);
    Exceptions
    Type Condition
    ArgumentNullException

    If addressis null.

    | Improve this Doc View Source

    LookupClient(IPAddress[])

    Creates a new instance of LookupClient with default settings and one or more DNS servers identified by their IPAddress. The default port 53 will be used for all IPAddresss provided.

    Declaration
    public LookupClient(params IPAddress[] nameServers)
    Parameters
    Type Name Description
    IPAddress[] nameServers

    The IPAddress(s) to be used by this LookupClient instance.

    Examples

    Connecting to one or more DNS server using the default port:

    // configuring the client to use google's public IPv4 DNS servers.
    var client = new LookupClient(IPAddress.Parse("8.8.8.8"), IPAddress.Parse("8.8.4.4"));
    Exceptions
    Type Condition
    ArgumentNullException

    If nameServersis null.

    | Improve this Doc View Source

    LookupClient(IPEndPoint[])

    Creates a new instance of LookupClient with default settings and the given name servers.

    Declaration
    public LookupClient(params IPEndPoint[] nameServers)
    Parameters
    Type Name Description
    IPEndPoint[] nameServers

    The IPEndPoint(s) to be used by this LookupClient instance.

    Examples

    Connecting to one specific DNS server which does not run on the default port 53:

    var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 8600);
    var client = new LookupClient(endpoint);

    The NameServer class also contains pre defined IPEndPoints for the public google DNS servers, which can be used as follows:

    var client = new LookupClient(NameServer.GooglePublicDns, NameServer.GooglePublicDnsIPv6);

    Exceptions
    Type Condition
    ArgumentNullException

    If nameServersis null.

    Properties

    | Improve this Doc View Source

    ContinueOnDnsError

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool ContinueOnDnsError { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    EnableAuditTrail

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool EnableAuditTrail { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    MinimumCacheTimeout

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public TimeSpan? MinimumCacheTimeout { get; set; }
    Property Value
    Type Description
    Nullable<TimeSpan>
    | Improve this Doc View Source

    NameServers

    Gets the list of configured or resolved name servers of the ILookupClient instance.

    Declaration
    public IReadOnlyCollection<NameServer> NameServers { get; }
    Property Value
    Type Description
    IReadOnlyCollection<NameServer>
    | Improve this Doc View Source

    Recursion

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool Recursion { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    Retries

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public int Retries { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    Settings

    Gets the configured settings of the ILookupClient instance.

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

    ThrowDnsErrors

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool ThrowDnsErrors { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    Timeout

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public TimeSpan Timeout { get; set; }
    Property Value
    Type Description
    TimeSpan
    | Improve this Doc View Source

    UseCache

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool UseCache { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    UseRandomNameServer

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool UseRandomNameServer { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    UseTcpFallback

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool UseTcpFallback { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    UseTcpOnly

    Declaration
    [Obsolete("This property will be removed from LookupClient in the next version. Use LookupClientOptions to initialize LookupClient instead.")]
    public bool UseTcpOnly { get; set; }
    Property Value
    Type Description
    Boolean

    Methods

    | Improve this Doc View Source

    GetReverseQuestion(IPAddress)

    Gets a reverse lookup question for an IPAddress.

    Declaration
    public static DnsQuestion GetReverseQuestion(IPAddress ipAddress)
    Parameters
    Type Name Description
    IPAddress ipAddress

    The address.

    Returns
    Type Description
    DnsQuestion

    A DnsQuestion with the proper arpa domain query for the given address.

    | Improve this Doc View Source

    Query(DnsQuestion)

    Performs a DNS lookup for the given question.

    Declaration
    public IDnsQueryResponse Query(DnsQuestion question)
    Parameters
    Type Name Description
    DnsQuestion question

    The domain name query.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If question is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    Query(DnsQuestion, DnsQueryAndServerOptions)

    Performs a DNS lookup for the given question.

    Declaration
    public IDnsQueryResponse Query(DnsQuestion question, DnsQueryAndServerOptions queryOptions)
    Parameters
    Type Name Description
    DnsQuestion question

    The domain name query.

    DnsQueryAndServerOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If question or queryOptions is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    Query(String, QueryType, QueryClass)

    Performs a DNS lookup for the given query, queryType and queryClass.

    Declaration
    public IDnsQueryResponse Query(string query, QueryType queryType, QueryClass queryClass = QueryClass.IN)
    Parameters
    Type Name Description
    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If query is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryAsync(DnsQuestion, DnsQueryAndServerOptions, CancellationToken)

    Performs a DNS lookup for the given question.

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(DnsQuestion question, DnsQueryAndServerOptions queryOptions, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    DnsQuestion question

    The domain name query.

    DnsQueryAndServerOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If question or queryOptions is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryAsync(DnsQuestion, CancellationToken)

    Performs a DNS lookup for the given question.

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(DnsQuestion question, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    DnsQuestion question

    The domain name query.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If question is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryAsync(String, QueryType, QueryClass, CancellationToken)

    Performs a DNS lookup for the given query, queryType and queryClass

    Declaration
    public Task<IDnsQueryResponse> QueryAsync(string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Exceptions
    Type Condition
    ArgumentNullException

    If query is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryReverse(IPAddress)

    Does a reverse lookup for the ipAddress.

    Declaration
    public IDnsQueryResponse QueryReverse(IPAddress ipAddress)
    Parameters
    Type Name Description
    IPAddress ipAddress

    The IPAddress.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentNullException

    If ipAddress is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryReverse(IPAddress, DnsQueryAndServerOptions)

    Does a reverse lookup for the ipAddress.

    Declaration
    public IDnsQueryResponse QueryReverse(IPAddress ipAddress, DnsQueryAndServerOptions queryOptions)
    Parameters
    Type Name Description
    IPAddress ipAddress

    The IPAddress.

    DnsQueryAndServerOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentNullException

    If ipAddress is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryReverseAsync(IPAddress, DnsQueryAndServerOptions, CancellationToken)

    Does a reverse lookup for the ipAddress.

    Declaration
    public Task<IDnsQueryResponse> QueryReverseAsync(IPAddress ipAddress, DnsQueryAndServerOptions queryOptions, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IPAddress ipAddress

    The IPAddress.

    DnsQueryAndServerOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentNullException

    If ipAddress is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryReverseAsync(IPAddress, CancellationToken)

    Does a reverse lookup for the ipAddress.

    Declaration
    public Task<IDnsQueryResponse> QueryReverseAsync(IPAddress ipAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IPAddress ipAddress

    The IPAddress.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentNullException

    If ipAddress is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServer(IReadOnlyCollection<NameServer>, DnsQuestion)

    Performs a DNS lookup for the given question using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServer(IReadOnlyCollection<NameServer> servers, DnsQuestion question)
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    DnsQuestion question

    The domain name query.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or question is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServer(IReadOnlyCollection<NameServer>, DnsQuestion, DnsQueryOptions)

    Performs a DNS lookup for the given question using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServer(IReadOnlyCollection<NameServer> servers, DnsQuestion question, DnsQueryOptions queryOptions)
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    DnsQuestion question

    The domain name query.

    DnsQueryOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers, question or queryOptions is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServer(IReadOnlyCollection<NameServer>, String, QueryType, QueryClass)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServer(IReadOnlyCollection<NameServer> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN)
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServer(IReadOnlyCollection<IPAddress>, String, QueryType, QueryClass)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServer(IReadOnlyCollection<IPAddress> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN)
    Parameters
    Type Name Description
    IReadOnlyCollection<IPAddress> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServer(IReadOnlyCollection<IPEndPoint>, String, QueryType, QueryClass)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServer(IReadOnlyCollection<IPEndPoint> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN)
    Parameters
    Type Name Description
    IReadOnlyCollection<IPEndPoint> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerAsync(IReadOnlyCollection<NameServer>, DnsQuestion, DnsQueryOptions, CancellationToken)

    Performs a DNS lookup for the given question using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerAsync(IReadOnlyCollection<NameServer> servers, DnsQuestion question, DnsQueryOptions queryOptions, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    DnsQuestion question

    The domain name query.

    DnsQueryOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers, question or queryOptions is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerAsync(IReadOnlyCollection<NameServer>, DnsQuestion, CancellationToken)

    Performs a DNS lookup for the given question using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerAsync(IReadOnlyCollection<NameServer> servers, DnsQuestion question, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    DnsQuestion question

    The domain name query.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or question is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerAsync(IReadOnlyCollection<NameServer>, String, QueryType, QueryClass, CancellationToken)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerAsync(IReadOnlyCollection<NameServer> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerAsync(IReadOnlyCollection<IPAddress>, String, QueryType, QueryClass, CancellationToken)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerAsync(IReadOnlyCollection<IPAddress> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<IPAddress> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerAsync(IReadOnlyCollection<IPEndPoint>, String, QueryType, QueryClass, CancellationToken)

    Performs a DNS lookup for the given query, queryType and queryClass using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerAsync(IReadOnlyCollection<IPEndPoint> servers, string query, QueryType queryType, QueryClass queryClass = QueryClass.IN, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<IPEndPoint> servers

    The list of one or more server(s) which should be used for the lookup.

    String query

    The domain name query.

    QueryType queryType

    The QueryType.

    QueryClass queryClass

    The QueryClass.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which contains the response headers and lists of resource records.

    Remarks

    To query specific servers can be useful in cases where you have to use a different DNS server than initially configured (without creating a new instance of ILookupClient for example).

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If query is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverse(IReadOnlyCollection<NameServer>, IPAddress)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServerReverse(IReadOnlyCollection<NameServer> servers, IPAddress ipAddress)
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverse(IReadOnlyCollection<NameServer>, IPAddress, DnsQueryOptions)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServerReverse(IReadOnlyCollection<NameServer> servers, IPAddress ipAddress, DnsQueryOptions queryOptions)
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    DnsQueryOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers, ipAddress or queryOptions is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverse(IReadOnlyCollection<IPAddress>, IPAddress)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServerReverse(IReadOnlyCollection<IPAddress> servers, IPAddress ipAddress)
    Parameters
    Type Name Description
    IReadOnlyCollection<IPAddress> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverse(IReadOnlyCollection<IPEndPoint>, IPAddress)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public IDnsQueryResponse QueryServerReverse(IReadOnlyCollection<IPEndPoint> servers, IPAddress ipAddress)
    Parameters
    Type Name Description
    IReadOnlyCollection<IPEndPoint> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    Returns
    Type Description
    IDnsQueryResponse

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverseAsync(IReadOnlyCollection<NameServer>, IPAddress, DnsQueryOptions, CancellationToken)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerReverseAsync(IReadOnlyCollection<NameServer> servers, IPAddress ipAddress, DnsQueryOptions queryOptions, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    DnsQueryOptions queryOptions

    Query options to be used instead of LookupClient's settings.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers, ipAddress or queryOptions is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverseAsync(IReadOnlyCollection<NameServer>, IPAddress, CancellationToken)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerReverseAsync(IReadOnlyCollection<NameServer> servers, IPAddress ipAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<NameServer> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverseAsync(IReadOnlyCollection<IPAddress>, IPAddress, CancellationToken)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerReverseAsync(IReadOnlyCollection<IPAddress> servers, IPAddress ipAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<IPAddress> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    | Improve this Doc View Source

    QueryServerReverseAsync(IReadOnlyCollection<IPEndPoint>, IPAddress, CancellationToken)

    Does a reverse lookup for the ipAddress using only the passed in servers.

    Declaration
    public Task<IDnsQueryResponse> QueryServerReverseAsync(IReadOnlyCollection<IPEndPoint> servers, IPAddress ipAddress, CancellationToken cancellationToken = default(CancellationToken))
    Parameters
    Type Name Description
    IReadOnlyCollection<IPEndPoint> servers

    The list of one or more server(s) which should be used for the lookup.

    IPAddress ipAddress

    The IPAddress.

    CancellationToken cancellationToken

    The cancellation token.

    Returns
    Type Description
    Task<IDnsQueryResponse>

    The IDnsQueryResponse which might contain the PtrRecord for the ipAddress.

    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    If the servers collection doesn't contain any elements.

    ArgumentNullException

    If servers or ipAddress is null.

    OperationCanceledException

    If cancellation has been requested for the passed in cancellationToken.

    DnsResponseException

    After retries and fallbacks, if none of the servers were accessible, timed out or (if ThrowDnsErrors is enabled) returned error results.

    Implements

    ILookupClient
    IDnsQuery

    Extension Methods

    DnsQueryExtensions.GetHostEntry(IDnsQuery, String)
    DnsQueryExtensions.GetHostEntryAsync(IDnsQuery, String)
    DnsQueryExtensions.GetHostEntry(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostEntryAsync(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostName(IDnsQuery, IPAddress)
    DnsQueryExtensions.GetHostNameAsync(IDnsQuery, IPAddress)
    DnsQueryExtensions.ResolveService(IDnsQuery, String, String, ProtocolType)
    DnsQueryExtensions.ResolveServiceAsync(IDnsQuery, String, String, ProtocolType)
    DnsQueryExtensions.ResolveService(IDnsQuery, String, String, String)
    DnsQueryExtensions.ResolveServiceAsync(IDnsQuery, String, String, String)

    See Also

    IDnsQuery
    ILookupClient
    • Improve this Doc
    • View Source
    © 2025 by Michael Conrad. All rights reserved. - MichaCo.net