This is my first python script (script and programming in general). I have a list of IPs that i would like to run reverse dig on each one. I found the easiest way is to write python script to do just that. The output does not look promising. Can someone please point what i am doing wrong. TIA
from subprocess import call
f_file = open("NET-DNS.txt", "r")
for IP in f_file.readlines():
call("dig @4.2.2.2 ANY -x " + IP + "+short")
f_file.close()
output:
; <<>> DiG 9.12.3 <<>> @4.2.2.2 ANY -x 98.138.219.231
+short
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35543
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 8192
;; QUESTION SECTION:
;231\010+short.219.138.98.in-addr.arpa. IN ANY
;; ANSWER SECTION:
231\010+short.219.138.98.in-addr.arpa. 1560 IN PTR UNKNOWN-98-138-219-X.yahoo.com.
;; AUTHORITY SECTION:
219.138.98.in-addr.arpa. 9832 IN NS ns3.yahoo.com.
219.138.98.in-addr.arpa. 9832 IN NS ns1.yahoo.com.
219.138.98.in-addr.arpa. 9832 IN NS ns5.yahoo.com.
219.138.98.in-addr.arpa. 9832 IN NS ns4.yahoo.com.
219.138.98.in-addr.arpa. 9832 IN NS ns2.yahoo.com.
;; Query time: 9 msec
;; SERVER: 4.2.2.2#53(4.2.2.2)
;; WHEN: Thu Dec 06 06:01:11 Pacific Standard Time 2018
;; MSG SIZE rcvd: 197
;; communications error to 4.2.2.2#53: end of file
; <<>> DiG 9.12.3 <<>> @4.2.2.2 ANY -x 98.138.219.231
+short
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1539
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 5, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 8192
;; QUESTION SECTION:
;231\010+short.219.138.98.in-addr.arpa. IN ANY
;; ANSWER SECTION:
231\010+short.219.138.98.in-addr.arpa. 1555 IN PTR UNKNOWN-98-138-219-X.yahoo.com.
;; AUTHORITY SECTION:
219.138.98.in-addr.arpa. 9827 IN NS ns3.yahoo.com.
219.138.98.in-addr.arpa. 9827 IN NS ns1.yahoo.com.
219.138.98.in-addr.arpa. 9827 IN NS ns5.yahoo.com.
219.138.98.in-addr.arpa. 9827 IN NS ns4.yahoo.com.
219.138.98.in-addr.arpa. 9827 IN NS ns2.yahoo.com.
;; Query time: 9 msec
;; SERVER: 4.2.2.2#53(4.2.2.2)
;; WHEN: Thu Dec 06 06:01:16 Pacific Standard Time 2018
;; MSG SIZE rcvd: 197
;; communications error to 4.2.2.2#53: end of file
;; communications error to 4.2.2.2#53: end of file
Process finished with exit code 0