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.
Implements
Inherited Members
Namespace: DnsClient
Assembly: DnsClient.dll
Syntax
public class NameServer : IEquatable<NameServer>
Constructors
| Improve this Doc View SourceNameServer(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 |
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 |
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 |
Fields
| Improve this Doc View SourceCloudflare
A public Cloudflare DNS endpoint.
Declaration
public static readonly IPEndPoint Cloudflare
Field Value
Type | Description |
---|---|
IPEndPoint |
Cloudflare2
A public Cloudflare DNS endpoint.
Declaration
public static readonly IPEndPoint Cloudflare2
Field Value
Type | Description |
---|---|
IPEndPoint |
Cloudflare2IPv6
A public Cloudflare DNS IPv6 endpoint.
Declaration
public static readonly IPEndPoint Cloudflare2IPv6
Field Value
Type | Description |
---|---|
IPEndPoint |
CloudflareIPv6
A public Cloudflare DNS IPv6 endpoint.
Declaration
public static readonly IPEndPoint CloudflareIPv6
Field Value
Type | Description |
---|---|
IPEndPoint |
DefaultPort
The default DNS server port.
Declaration
public const int DefaultPort = 53
Field Value
Type | Description |
---|---|
Int32 |
GooglePublicDns
The public google DNS IPv4 endpoint.
Declaration
public static readonly IPEndPoint GooglePublicDns
Field Value
Type | Description |
---|---|
IPEndPoint |
GooglePublicDns2
The second public google DNS IPv6 endpoint.
Declaration
public static readonly IPEndPoint GooglePublicDns2
Field Value
Type | Description |
---|---|
IPEndPoint |
GooglePublicDns2IPv6
The second public google DNS IPv6 endpoint.
Declaration
public static readonly IPEndPoint GooglePublicDns2IPv6
Field Value
Type | Description |
---|---|
IPEndPoint |
GooglePublicDnsIPv6
The public google DNS IPv6 endpoint.
Declaration
public static readonly IPEndPoint GooglePublicDnsIPv6
Field Value
Type | Description |
---|---|
IPEndPoint |
Properties
| Improve this Doc View SourceAddress
Gets the string representation of the configured IPAddress.
Declaration
public string Address { get; }
Property Value
Type | Description |
---|---|
String |
AddressFamily
Gets the address family.
Declaration
public AddressFamily AddressFamily { get; }
Property Value
Type | Description |
---|---|
AddressFamily |
Port
Gets the port.
Declaration
public int Port { get; }
Property Value
Type | Description |
---|---|
Int32 |
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 SourceEquals(NameServer)
Declaration
public bool Equals(NameServer other)
Parameters
Type | Name | Description |
---|---|---|
NameServer | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceResolveNameServers(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 |
Boolean | fallbackToGooglePublicDns | If set to |
Returns
Type | Description |
---|---|
IReadOnlyCollection<NameServer> | The list of name servers. |
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.
ToString()
Returns a String that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A String that represents this instance. |
Overrides
Operators
| Improve this Doc View SourceImplicit(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 |
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 |