fehQlibs 27
Qlibs
Loading...
Searching...
No Matches
dnsstub Directory Reference
Directory dependency graph for dnsstub:
fehQlibs-27/src/dnsstub

Files

 dns_cname.c
 DNS cname lookup.
 
 dns_dfd.c
 domain name qualification (domain from dot)
 
 dns_domain.c
 domain qualification
 
 dns_dtda.c
 domain to dot append
 
 dns_ip.c
 DNS IP query.
 
 dns_ipq.c
 DNS hostname qualification for ipv4 and ipv6.
 
 dns_mx.c
 dns MX query
 
 dns_name.c
 DNS name query (ptr)
 
 dns_nd.c
 DNS domain name for ip (wire format)
 
 dns_packet.c
 DNS low level packet routine.
 
 dns_random.c
 random use of DNS resolvers given their IP
 
 dns_rcip.c
 DNS receive for query.
 
 dns_rcrw.c
 DNS receive rewrite.
 
 dns_resolve.c
 high-level DNS resolve function
 
 dns_sortip.c
 random sort of DNS servers per IP
 
 dns_transmit.c
 DNS query function.
 
 dns_txt.c
 DNS text query (txt)
 

Detailed Description

Simple DJBDNS stub-resolver based on 'djbdns-1.05(IPv6)' allowing for each calling application individually to include up to 16 DNSCACHEIP(s) as DNS forwarding/resolving servers to be tried sequentially.

IP Addresses

Here,

In any case, compactified IPv6 addresses are understood. IPv4/IPv6 addresses in brackets are understood by dns_ip.

Resolver Call

If $DNSCACHEIP is not provided as environment variable, the stub-resolver will use the system-wide

Name Qualification

If provided, the stub-resolver uses either a system-wide configuration file

Well-known domain names 'localhost', 'ip4-loopback' and 'ip6-loopback' are handled locally, thus no DNS query is used (RFC 6761). 'localhost' is advertised as '::1' and '::ff:127.0.0.1' in it's native IPv6 format. It is up to the caller to convert the IPv6-mapped IPv4 address to the IPv4 format.

Local domain names can be alternatively specified (per application) using the environment variable

See: https://cr.yp.to/djbdns/qualify.html

Specific DNS Record type lookup

Internals

For return codes < 0, the following conventions have been applied:

    include/dnsresolv.h

#define DNS_NXD 0 #define DNS_MEM -1 #define DNS_ERR -2 /* parsing errors and others */ #define DNS_COM -3 /* (socket) communication errors */ #define DNS_INT -4 /* internal errors */ #define DNS_SOFT -5 /* either -2 or -3 */ #define DNS_HARD -6 /* CNAME loop problem */

The modification of the return code is typically not problematic, since mostly just rc = -1 is checked.

In the future, these return codes are subject of change. Thus, instead of

if (dns_XX(...) == -1)

one shoud use the more general syntax

if (dns_XX(...) < 0)

to check for 'negative' results, allowing further actions and refinements given the calling sequence.

Environment Variables Read

$DNSCACHEPIP The upstream resolver's IP[v4|v6] addresses (up to 32). IPv6 LLU addresses may be suffixed with the interface name. $DNSREWRITEFILE Alternate location for the system-wide /etc/dnsrewrite file $LOCALDOMAIN Additional local domain name appended to unqualified hostnames dynamically.

Sample for the file /etc/dnsrewrite:

#annything.local -> me -.example.com:me # me -> 127.0.0.1 =me:127.0.0.1 # any.name.a -> any.name.af.mil *.a:.af.mil # any-name-without-dots -> any-name-without-dots.heaven.af.mil ?:.heaven.af.mil # remove trailing dot *.:

and DJB's explanations are given here:

Instructions are followed in order, each at most once. There are four types of instructions:

=post:new means that the host name post is replaced by new. *post:new means that any name of the form prepost is replaced by prenew. ?post:new means that any name of the form prepost, where pre does not contain dots or brackets, is replaced by prenew. -post:new means that any name of the form prepost is replaced by new.

Erwin Hoffmann, June 2023.