Python-dnspython Module

Source: Internet
Author: User

Dnspython is a Python-implemented DNS toolkit that supports almost all record types and can be used to query, transmit, and dynamically update zone information while supporting TSIG authentication information and EDNS0. In System management, we can use its query function to implement DNS service monitoring and validation of the results, can replace the nslookup and dig tools.

First install the Dnspython module


Dnspython module provides a large number of DNS processing methods, the most common method is the domain name query. It provides a DNS resolver class (resolver) that uses the query method of this class to implement the querying function of the domain name. Definition of the Query method:

Query (self,qname,rdtype=1,rdclass=1,tcp=false,source=none,raise_on_no_answer=true,source_port=0)

Where the QName parameter is the domain name of the query. The Rdtype parameter is used to specify the type of RR resource, and the commonly used types are as follows:

1>:a record, convert host name to IP address

2>:MX Records, mail exchange records, define the domain name of the mail server

3>:cname Record, alias Record, to realize the mapping between domain names

4>:ns records, domain name servers and authorization subdomains for labeled zones

5>:ptr Records, reverse parsing, and a record instead, convert IP address to host name

6>:soa records, SOA tags, a starting authorization area definition.

The Rdclass parameter is used to specify the network type, with an optional value of in, CH, and HS, where in is the default. The TCP parameter is used to specify whether the query enables the TCP protocol, which is not enabled by default. Source with the Source_port parameter as the specified query for the origin address and port, the default value is query device IP and 0. The Raise_on_no_answer parameter specifies whether to trigger an exception when the query has no answer, which is true by default.

1, a record of the Query method

2, the MX record Query method

3, NS records of the Query method


4, the CNAME record query method



Python-dnspython Module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.