dns¶
DNS module.
-
class
spicerack.dns.
Dns
(*, nameserver_address: Optional[str] = None, port: Optional[int] = None)[source]¶ Class to interact with the DNS.
Initialize the instance.
- Parameters
-
resolve
(qname: Union[str, dns.name.Name], record_type: str) → dns.resolver.Answer[source]¶ Perform a DNS lookup for the given qname and record type.
- Parameters
- Returns
the DNS response.
- Return type
dns.resolver.Answer
- Raises
spicerack.dns.DnsNotFound -- if there are no records for the given record type but the qname has records for different record type(s).
spicerack.dns.DnsError -- on generic error.
-
resolve_ips
(name: str) → List[str][source]¶ Perform a DNS lookup for A and AAAA records for the given name.
- Parameters
name (str) -- the name to resolve.
- Returns
the list of IPv4 and IPv6 addresses as strings returned by the DNS response.
- Return type
- Raises
spicerack.dns.DnsNotFound -- when no address is found.
-
resolve_ipv4
(name: str) → List[str][source]¶ Perform a DNS lookup for an A record for the given name.