Created
February 16, 2022 06:56
-
-
Save patsevanton/7bb376c885f3254ce66f4485606176ec to your computer and use it in GitHub Desktop.
compare_dns
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import subprocess | |
import six | |
import sys | |
dns_zone_domain_ru = subprocess.Popen("host -l domain.ru 10.0.0.1", shell=True, stdout=subprocess.PIPE) | |
list_fqdn = dns_zone_domain_ru.communicate() | |
for i in list_fqdn: | |
if isinstance(i, six.string_types): | |
for j in i.splitlines(): | |
if "has address" in j: | |
# print(j.split()[0],j.split()[3],) | |
fqdn = j.split()[0] | |
ipaddress = j.split()[3] | |
# print(type(ipaddress)) | |
query_to_test_dns_server = subprocess.Popen("dig +short " + fqdn + " @10.0.0.2", shell=True, stdout=subprocess.PIPE) | |
output = query_to_test_dns_server.communicate() | |
for k in output: | |
if isinstance(k, six.string_types): | |
for ipaddress_other_dns in k.splitlines(): | |
if ipaddress != ipaddress_other_dns: | |
print(fqdn + ' have different ip address:') | |
print('on test-dns1: ' + ipaddress) | |
print('on test-dns2: ' + ipaddress_other_dns) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment