Skip to content

Instantly share code, notes, and snippets.

@cwedgwood
Created November 9, 2018 00:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cwedgwood/17db5a7df2ea80acf92385632662348a to your computer and use it in GitHub Desktop.
Save cwedgwood/17db5a7df2ea80acf92385632662348a to your computer and use it in GitHub Desktop.
Using python to get a list of IPs from DNS
#!/usr/bin/python2.7
# https://docs.python.org/2.7/library/socket.html#socket.getaddrinfo
import socket
[ addr[4][0] for addr in socket.getaddrinfo("google.com", 0) if addr[0] in (socket.AF_INET, socket.AF_INET6) ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment