Skip to content

Instantly share code, notes, and snippets.

@subtosilencio
Created August 25, 2021 23:57
Show Gist options
  • Save subtosilencio/8883481d825bd7fccffcabecd50f102f to your computer and use it in GitHub Desktop.
Save subtosilencio/8883481d825bd7fccffcabecd50f102f to your computer and use it in GitHub Desktop.
Return DNS servers of a domain
import subprocess
def returnDNS(domain):
''' Return DNS servers of a domain '''
proc = subprocess.Popen(["dig +short +time=2 -t ns " +domain],
stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
return sorted(out.decode('utf-8').split())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment