File: example4.rst

package info (click to toggle)
unbound 1.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,436 kB
  • sloc: ansic: 138,476; sh: 6,860; yacc: 4,259; python: 1,950; makefile: 1,881; awk: 162; perl: 158; xml: 36
file content (36 lines) | stat: -rw-r--r-- 903 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.. _example_examine:

DNSSEC validator
================

This example program performs DNSSEC validation of a DNS lookup.

Source code
-----------

::

    #!/usr/bin/python
    import os
    from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN

    ctx = ub_ctx()
    ctx.resolvconf("/etc/resolv.conf")
    if (os.path.isfile("keys")):
        ctx.add_ta_file("keys") #read public keys for DNSSEC verification

    status, result = ctx.resolve("www.nic.cz", RR_TYPE_A, RR_CLASS_IN)
    if status == 0 and result.havedata:

        print "Result:", result.data.address_list

        if result.secure:
            print "Result is secure"
        elif result.bogus:
            print "Result is bogus"
        else:
            print "Result is insecure"

More detailed information can be seen in libUnbound DNSSEC tutorial `here`_.

.. _here: http://www.unbound.net/documentation/libunbound-tutorial-6.html