[ldns-users] Fwd: Regarding dns resolver in c using ldns
Willem Toorop
willem at nlnetlabs.nl
Wed May 18 12:28:49 UTC 2016
Hi Ravin,
This is a little of a chicken and egg problem :).
I suspect you want to target the authoritative nameservers for a given
domain. In that case you have to find out which authoritative
nameservers serve that domain and their IP addresses first.
So to target the authoritative nameservers serving domain.com, you first
have to query for the NS RRset for domain.com (perhaps with a
ldns_resolver initialized with /etc/resolv.conf ; i.e.
ldns_resolver_new_frm_fp(&res, NULL)).
Below is the query done with drill, but it could be done with a
ldns_resolver initialized with /etc/resolv.conf just as well...
$ drill domain.com NS
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 59096
;; flags: qr rd ra ; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 4
;; QUESTION SECTION:
;; domain.com. IN NS
;; ANSWER SECTION:
domain.com. 86400 IN NS ns1.p13.dynect.net.
domain.com. 86400 IN NS ns2.p13.dynect.net.
domain.com. 86400 IN NS ns3.p13.dynect.net.
domain.com. 86400 IN NS ns4.p13.dynect.net.
;; AUTHORITY SECTION:
;; ADDITIONAL SECTION:
ns1.p13.dynect.net. 68784 IN A 208.78.70.13
ns2.p13.dynect.net. 68784 IN A 204.13.250.13
ns3.p13.dynect.net. 68784 IN A 208.78.71.13
ns4.p13.dynect.net. 68784 IN A 204.13.251.13
;; Query time: 454 msec
;; SERVER: 185.49.140.101
;; WHEN: Wed May 18 14:21:03 2016
;; MSG SIZE rcvd: 178
Now push those IP addresses in the additional section on the
ldns_resolver with which you want to target the authoritative
nameserver. (you might have to do more lookups to get the addresses
though...)
Is this helpful to you?
-- Willem
Op 18-05-16 om 14:08 schreef ravin goyal:
> Hii Willem
>
> Regarding ldns_resolver_push_nameserver to target a server directly
> with a query , in the example code that you have sent using
>
> while creating nameserver address you have done this :
>
> ldns_rdf_new_frm_str( LDNS_RDF_TYPE_A, "185.49.140.60")
>
> but in here i want to set the domain name rather than the ip address itself
>
> I tried using ldns_rdf_new_frm_str( LDNS_RDF_TYPE_DNAME, "domain.com")
>
> but it is not working
>
> How can we set the domain name of the nameserver rather than ip address
>
>
> thanks in advance.
>
More information about the ldns-users
mailing list