DNS Lookup¶
Problematic¶
How can we check if a domain or IP have a DNS pointer?
Documentation¶
The tool to check the availability or syntax of domains, IPv4 or URL.
██████╗ ██╗ ██╗███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗██████╗ ██╗ ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝██╔══██╗██║ ██╔════╝
██████╔╝ ╚████╔╝ █████╗ ██║ ██║██╔██╗ ██║██║ █████╗ ██████╔╝██║ █████╗
██╔═══╝ ╚██╔╝ ██╔══╝ ██║ ██║██║╚██╗██║██║ ██╔══╝ ██╔══██╗██║ ██╔══╝
██║ ██║ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝
This submodule will provide the DNS lookup interface.
- Author:
- Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
- Special thanks:
- https://pyfunceble.github.io/special-thanks.html
- Contributors:
- https://pyfunceble.github.io/contributors.html
- Project link:
- https://github.com/funilrys/PyFunceble
- Project documentation:
- https://pyfunceble.readthedocs.io/en/master/
- Project homepage:
- https://pyfunceble.github.io/
License:
MIT License
Copyright (c) 2017, 2018, 2019 Nissar Chababy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-
class
PyFunceble.dns_lookup.
DNSLookup
(subject, dns_server=None, complete=False)[source]¶ DNS lookup interface.
Parameters: - subject (str) – The subject we are working with.
- dns_server (list|tuple|str) – The DNS server we are working with.
-
_DNSLookup__request_ipv4
()¶ Handle the request for a subject which is IPv4.
-
_DNSLookup__request_not_ipv4
()¶ Handle the request for a subject which is not an IPv4.
-
a_record
(subject=None, lifetime=3.0)[source]¶ Return the A record of the given subject (if found).
Parameters: - subject (str) – The subject we are working with.
- lifetime (float) – The number of second before timeout.
Returns: A list of A record(s).
Return type: list
-
aaaa_record
(subject=None, lifetime=3.0)[source]¶ Return the AAAA record of the given subject (if found).
Parameters: - subject (str) – The subject we are working with.
- lifetime (float) – The number of second before timeout.
Returns: A list of A record(s).
Return type: list
-
cname_record
(subject=None, lifetime=3.0)[source]¶ Return the CNAME record of the given subject (if found).
Parameters: - subject (str) – The subject we are working with.
- lifetime (float) – The number of second before timeout.
Returns: A list of CNAME record(s).
Return type: list
-
get_addr_info
(subject=None)[source]¶ Get and return the information of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A list of address. Return type: list
-
get_host_by_addr
(subject=None)[source]¶ Get and return the host of the given subject (address).
Parameters: subject (str) – The subject we are working with. Returns: A dict in the following format or None
.{ "hostname": "", "aliases": [], "ips": [] }
Return type: list
-
mx_record
(subject=None, lifetime=3.0)[source]¶ Return the MX record of the given subject (if found).
Parameters: - subject (str) – The subject we are working with.
- lifetime (float) – The number of second before timeout.
Returns: A list of MX record(s).
Return type: list
-
ns_record
(subject=None, lifetime=3.0)[source]¶ Return the NS record of the given subject (if found).
Parameters: subject (str) – The subject we are working with. :param float lifetime: The number of second before timeout. Returns: A list of NS record(s). Return type: list
-
ptr_record
(subject=None, reverse_name=True, lifetime=3.0)[source]¶ Return the PTR record of the given subject (if found).
Parameters: - subject (str) – The subject we are working with.
- lifetime (float) – The number of second before timeout.
Returns: A list of PTR record(s).
Return type: list
-
request
()[source]¶ Perform the NS request.
Returns: A dict with following index if the given subject is not registered into the given DNS server. (More likely local subjects). { "hostname": "", "aliases": [], "ips": [] }
A dict with following index for everything else (and if found).
{ "A": [], "AAAA": [], "CNAME": [], "MX": [], "NS": [], "TXT": [], "PTR": [] }
Return type: dict