Python---Dnspython

Source: Internet
Author: User

Dnspython is a Python-implemented DNS toolkit that supports almost all record types, can be used for querying, transmitting, and dynamically updating zone information, while supporting Tsig (transactional signature) authentication messages and EDNS0 (extended DNS). Can replace tools such as Nslookup,dig.

#pip安装pip3 Install dnspython# Latest version v1.15.0
Module Domain Name resolution method detailed

Dnspython provides a number of DNS processing methods, the most commonly used is the domain name query.

Dnspython provides a DNS parser class------resolver, which uses its query method to implement the querying function of the domain name.

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

QName the domain name for the query

Rdtype used to specify the type of RR resource

A record, converting the hostname to an IP address

MX record, mail exchange record, define mail server domain name

CNAME records, alias Records, implementing mappings between domain names

NS records, domain name servers for labeled zones, and authorization subdomains

PTR records, reverse resolution, and a record instead, convert IP to host name

SOA record, definition of a starting authorization area

Rdclass is used to specify the network type, such as in,ch,hs,in as the default

TCP Specifies whether the query enables the TCP protocol, default false (not enabled)

Source,source_port Specify the query source address and Port

Raise_on_no_answer query Whether no answer triggers an exception

Common parsing Type Sample script

A record

#!/usr/bin/env python#-*-coding:utf-8-*-#Author: ccoo2import dns.resolver# domain = input ("Please enter the domain name address:") domain = ' Www.bai Du.com ' A = dns.resolver.query (domain, ' a ') for I in A.response.answer:    # Print (i) for    J in I.items:        print (j)

MX record

Python---Dnspython

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.