As you have installed ldns, now you may check out the Dyn's dns_lg source code from its source code repository:
git clone [email protected]:dyninc/dns_lg.git cd dns_lg/
Now, you may run the application simply by executing api.py. Running it produces the following output:
$ python api.py * Running on http://0.0.0.0:8185/
(Press CTRL+C to quit)
Now open another console window to run a curl:
curl http://0.0.0.0:8185/cnn.com/
This will output a line to the preceding api.py console:
127.0.0.1 - - [15/Jul/2017 23:33:40]
"GET /cnn.com/ HTTP/1.1" 200 -
The curl command produces the following output with the detailed DNS information from the looking glass implementation:
$ curl http://0.0.0.0:8185/cnn.com/ { "AdditionalSection": [ { "Address": "205.251.192.47", "Class": "IN", "Name": "ns-47.awsdns-05.com.", "TTL": "20545", "Type": "A" }, { "Address": "205.251.194.64", "Class": "IN", "Name": "ns-576.awsdns-08.net.", "TTL": "20545", "Type": "A" } ], "AnswerSection": [], "AuthoritySection": [ { "Class": "IN", "Name": "cnn.com.", "TTL": "20545", "Target": "ns-47.awsdns-05.com.", "Type": "NS" }, { "Class": "IN", "Name": "cnn.com.", "TTL": "20545", "Target": "ns-1086.awsdns-07.org.", "Type": "NS" }, { "Class": "IN", "Name": "cnn.com.", "TTL": "20545", "Target": "ns-576.awsdns-08.net.", "Type": "NS" }, { "Class": "IN", "Name": "cnn.com.", "TTL": "20545", "Target": "ns-1630.awsdns-11.co.uk.", "Type": "NS" } ], "None": "true", "Query": { "Duration": 118, "Server": "", "ServerIP": "127.0.1.1", "Versions": "Dyn DNS Looking Glass 1.0.0" }, "QuestionSection": { "Qclass": "IN", "Qname": "cnn.com.", "Qtype": "A" }, "ReturnCode": "NOERROR" }
The preceding output shows Dyn's dns_lg and curl in action. Please note that currently Dyn's dns_lg works only in Python 2.x. However, with some minor fixes, this can easily be ported to Python 3.x. As we ported bgperf to Python 3.x in a previous recipe, this is left as an exercise for those who like to port this to Python 3.x.