Home | History | Annotate | Line # | Download | only in examples
      1 #!/usr/bin/python
      2 from unbound import ub_ctx,ub_strerror,RR_TYPE_A,RR_CLASS_IN
      3 
      4 ctx = ub_ctx()
      5 ctx.resolvconf("/etc/resolv.conf")
      6 	
      7 status, result = ctx.resolve("test.record.xxx", RR_TYPE_A, RR_CLASS_IN)
      8 if status == 0 and result.havedata:
      9     print "Result:", result.data.address_list
     10 else:
     11     print "No record found"
     12 
     13 #define new local zone
     14 status = ctx.zone_add("xxx.","static")
     15 if (status != 0): print "Error zone_add:",status, ub_strerror(status)
     16 
     17 #add RR to the zone
     18 status = ctx.data_add("test.record.xxx. IN A 1.2.3.4")
     19 if (status != 0): print "Error data_add:",status, ub_strerror(status)
     20 
     21 #lookup for an A record
     22 status, result = ctx.resolve("test.record.xxx", RR_TYPE_A, RR_CLASS_IN)
     23 if status == 0 and result.havedata:
     24     print "Result:", result.data.as_address_list()
     25 else:
     26     print "No record found"
     27 
     28