DNS-checker
This commit is contained in:
parent
9b0a6a4c9f
commit
c2c4441c81
50
dns_checker.py
Executable file
50
dns_checker.py
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import argparse
|
||||
from prettytable import PrettyTable
|
||||
|
||||
TABLE_DNS = PrettyTable()
|
||||
TABLE_DNS.hrules = True
|
||||
DIG_CMD = 'dig {record} @{ns_server} {_type} +short'
|
||||
DEFAULT_DNS_SERVERS = [
|
||||
#добавить список любых DNS-серверов
|
||||
]
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Script for checking DNS records only.")
|
||||
|
||||
def get_params():
|
||||
|
||||
parser.add_argument(
|
||||
"-t", "--type",
|
||||
dest="_type",
|
||||
default='',
|
||||
metavar='A',
|
||||
help="Type of record for check, default use A-record ")
|
||||
|
||||
parser.add_argument(
|
||||
"-d", "--dns",
|
||||
dest="record",
|
||||
help="Domain for check",
|
||||
metavar='i-free.com')
|
||||
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
def main():
|
||||
|
||||
TABLE_DNS.field_names = ["NS-SERVER", "VALUE"]
|
||||
params = get_params()
|
||||
record = params.record
|
||||
_type = params._type
|
||||
|
||||
for ns_server in DEFAULT_DNS_SERVERS:
|
||||
cmd = DIG_CMD.format(record=record, _type=_type, ns_server=ns_server)
|
||||
value = os.popen(cmd).read()
|
||||
TABLE_DNS.add_row([ns_server, value.strip()])
|
||||
|
||||
print(TABLE_DNS)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
Reference in New Issue
Block a user