Output IPv6 addresses
authorZachary Seguin <ztseguin@csclub.uwaterloo.ca>
Mon, 29 Feb 2016 17:13:06 +0000 (12:13 -0500)
committerZachary Seguin <ztseguin@csclub.uwaterloo.ca>
Mon, 29 Feb 2016 17:13:06 +0000 (12:13 -0500)
generate-hosts.py
hosts.in

index 6a09862..42d2dde 100755 (executable)
@@ -7,6 +7,8 @@ import dns.resolver
 
 exp = re.compile('([^\.]+)')
 
+hosts = []
+
 if __name__ == '__main__':
 
 
@@ -21,9 +23,14 @@ if __name__ == '__main__':
          continue
 
       try:
-         res = dns.resolver.query(host)
-         ip = socket.gethostbyname(str(res.qname))
-
-         print("{0}\t{1} {2}".format(ip, str(res.qname)[:-1], exp.match(host).group(0)))
+         if True:
+            res = dns.resolver.query(host)
+            ips = socket.getaddrinfo(str(res.qname), None)
+
+            for ip in ips:
+               entry = (ip[4][0], str(res.qname)[:-1], exp.match(host).group(0))
+               if not entry in hosts:
+                  print("{0:45} {1} {2}".format(ip[4][0], str(res.qname)[:-1], exp.match(host).group(0)))
+                  hosts.append(entry)
       except:
          sys.stderr.write('Failed to get IP for: {0}\n'.format(host))
index b95e229..743aa9a 100644 (file)
--- a/hosts.in
+++ b/hosts.in
@@ -40,7 +40,6 @@ goto80
 
 # CSC - Syscom
 
-!129.97.134.5     hydrazine.csclub.uwaterloo.ca hydrazine
 auth1
 auth2
 ldap1
@@ -49,6 +48,9 @@ kdc1
 kdc2
 kadmin
 
+hydrazine
+electrons
+
 mail
 
 aspartame