13b6c3722Schristos.. _example_resolver_only: 23b6c3722Schristos 33b6c3722SchristosResolver only 4*0cd9f4ecSchristos============= 53b6c3722Schristos 63b6c3722SchristosThis example program shows how to perform DNS resolution only. 73b6c3722SchristosUnbound contains two basic modules: resolver and validator. 8*0cd9f4ecSchristosIn case, the validator is not necessary, the validator module can be turned off 9*0cd9f4ecSchristosusing "module-config" option. 10*0cd9f4ecSchristosThis option contains a list of module names separated by the space char. This 11*0cd9f4ecSchristoslist determined which modules should be employed and in what order. 12*0cd9f4ecSchristos 13*0cd9f4ecSchristosSource code 14*0cd9f4ecSchristos----------- 153b6c3722Schristos 163b6c3722Schristos:: 173b6c3722Schristos 183b6c3722Schristos #!/usr/bin/python 193b6c3722Schristos import os 203b6c3722Schristos from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN 213b6c3722Schristos 223b6c3722Schristos ctx = ub_ctx() 233b6c3722Schristos ctx.set_option("module-config:","iterator") 243b6c3722Schristos ctx.resolvconf("/etc/resolv.conf") 253b6c3722Schristos 263b6c3722Schristos status, result = ctx.resolve("www.google.com", RR_TYPE_A, RR_CLASS_IN) 273b6c3722Schristos if status == 0 and result.havedata: 283b6c3722Schristos 293b6c3722Schristos print "Result:", result.data.address_list 303b6c3722Schristos 313b6c3722Schristos.. note:: 32*0cd9f4ecSchristos The :meth:`unbound.ub_ctx.set_option` method must be used before the first 33*0cd9f4ecSchristos resolution (i.e. before :meth:`unbound.ub_ctx.resolve` or 34*0cd9f4ecSchristos :meth:`unbound.ub_ctx.resolve_async` call). 35