1dns(n) Domain Name Service dns(n)
2
3
4
5______________________________________________________________________________
6
8 dns - Tcl Domain Name Service Client
9
11 package require Tcl 8.2
12
13 package require dns ?1.3.3?
14
15 ::dns::resolve query ?options?
16
17 ::dns::configure ?options?
18
19 ::dns::name token
20
21 ::dns::address token
22
23 ::dns::cname token
24
25 ::dns::result token
26
27 ::dns::status token
28
29 ::dns::error token
30
31 ::dns::reset token
32
33 ::dns::wait token
34
35 ::dns::cleanup token
36
37 ::dns::nameservers
38
39_________________________________________________________________
40
42 The dns package provides a Tcl only Domain Name Service client. You
43 should refer to (1) and (2) for information about the DNS protocol or
44 read resolver(3) to find out how the C library resolves domain names.
45 The intention of this package is to insulate Tcl scripts from problems
46 with using the system library resolver for slow name servers. It may
47 or may not be of practical use. Internet name resolution is a complex
48 business and DNS is only one part of the resolver. You may find you are
49 supposed to be using hosts files, NIS or WINS to name a few other sys‐
50 tems. This package is not a substitute for the C library resolver - it
51 does however implement name resolution over DNS. The package also
52 extends the package uri to support DNS URIs (4) of the form
53 dns:what.host.com or dns://my.nameserver/what.host.com. The
54 dns::resolve command can handle DNS URIs or simple domain names as a
55 query.
56
57 Note: The package defaults to using DNS over TCP connections. If you
58 wish to use UDP you will need to have the tcludp package installed and
59 have a version that correctly handles binary data (> 1.0.4). This is
60 available at http://tcludp.sourceforge.net/. If the udp package is
61 present then UDP will be used by default.
62
64 ::dns::resolve query ?options?
65 Resolve a domain name using the DNS protocol. query is the
66 domain name to be lookup up. This should be either a fully qual‐
67 ified domain name or a DNS URI.
68
69 -nameserver hostname or -server hostname
70 Specify an alternative name server for this request.
71
72 -protocol tcp|udp
73 Specify the network protocol to use for this request. Can
74 be one of tcp or udp.
75
76 -port portnum
77 Specify an alternative port.
78
79 -search domainlist
80
81 -timeout milliseconds
82 Override the default timeout.
83
84 -type TYPE
85 Specify the type of DNS record you are interested in.
86 Valid values are A, NS, MD, MF, CNAME, SOA, MB, MG, MR,
87 NULL, WKS, PTR, HINFO, MINFO, MX, TXT, SPF, SRV, AAAA,
88 AXFR, MAILB, MAILA and *. See RFC1035 for details about
89 the return values. See http://spf.pobox.com/ about SPF.
90 See (3) about AAAA records and RFC2782 for details of SRV
91 records.
92
93 -class CLASS
94 Specify the class of domain name. This is usually IN but
95 may be one of IN for internet domain names, CS, CH, HS or
96 * for any class.
97
98 -recurse boolean
99 Set to false if you do not want the name server to recur‐
100 sively act upon your request. Normally set to true.
101
102 -command procname
103 Set a procedure to be called upon request completion. The
104 procedure will be passed the token as its only argument.
105
106
107 ::dns::configure ?options?
108 The ::dns::configure command is used to setup the dns package.
109 The server to query, the protocol and domain search path are all
110 set via this command. If no arguments are provided then a list
111 of all the current settings is returned. If only one argument
112 then it must the the name of an option and the value for that
113 option is returned.
114
115 -nameserver hostname
116 Set the default name server to be used by all queries.
117 The default is localhost.
118
119 -protocol tcp|udp
120 Set the default network protocol to be used. Default is
121 tcp.
122
123 -port portnum
124 Set the default port to use on the name server. The
125 default is 53.
126
127 -search domainlist
128 Set the domain search list. This is currently not used.
129
130 -timeout milliseconds
131 Set the default timeout value for DNS lookups. Default is
132 30 seconds.
133
134 -loglevel level
135 Set the log level used for emitting diagnostic messages
136 from this package. The default is warn. See the log pack‐
137 age for details of the available levels.
138
139
140 ::dns::name token
141 Returns a list of all domain names returned as an answer to your
142 query.
143
144
145 ::dns::address token
146 Returns a list of the address records that match your query.
147
148
149 ::dns::cname token
150 Returns a list of canonical names (usually just one) matching
151 your query.
152
153
154 ::dns::result token
155 Returns a list of all the decoded answer records provided for
156 your query. This permits you to extract the result for more
157 unusual query types.
158
159
160 ::dns::status token
161 Returns the status flag. For a successfully completed query this
162 will be ok. May be error or timeout or eof. See also
163 ::dns::error
164
165
166 ::dns::error token
167 Returns the error message provided for requests whose status is
168 error. If there is no error message then an empty string is
169 returned.
170
171
172 ::dns::reset token
173 Reset or cancel a DNS query.
174
175
176 ::dns::wait token
177 Wait for a DNS query to complete and return the status upon com‐
178 pletion.
179
180
181 ::dns::cleanup token
182 Remove all state variables associated with the request.
183
184
185 ::dns::nameservers
186 Attempts to return a list of the nameservers currently config‐
187 ured for the users system. On a unix machine this parses the
188 /etc/resolv.conf file for nameservers (if it exists) and on Win‐
189 dows systems we examine certain parts of the registry. If no
190 nameserver can be found then the loopback address (127.0.0.1) is
191 used as a default.
192
194 % set tok [dns::resolve www.tcl.tk]
195 ::dns::1
196 % dns::status $tok
197 ok
198 % dns::address $tok
199 199.175.6.239
200 % dns::name $tok
201 www.tcl.tk
202 % dns::cleanup $tok
203
204
205 Using DNS URIs as queries:
206
207 % set tok [dns::resolve "dns:tcl.tk;type=MX"]
208 % set tok [dns::resolve "dns://l.root-servers.net/www.tcl.tk"]
209
210
211 Reverse address lookup:
212
213 % set tok [dns::resolve 127.0.0.1]
214 ::dns::1
215 % dns::name $tok
216 localhost
217 % dns::cleanup $tok
218
219
221 [1] Mockapetris, P., "Domain Names - Concepts and Facilities", RFC
222 1034, November 1987. (http://www.ietf.org/rfc/rfc1034.txt)
223
224 [2] Mockapetris, P., "Domain Names - Implementation and Specifica‐
225 tion", RFC 1035, November 1087.
226 (http://www.ietf.org/rfc/rfc1035.txt)
227
228 [3] Thompson, S. and Huitema, C., "DNS Extensions to support IP ver‐
229 sion 6", RFC 1886, December 1995.
230 (http://www.ietf.org/rfc/rfc1886.txt)
231
232 [4] Josefsson, S., "Domain Name System Uniform Resource Identi‐
233 fiers", Internet-Draft, October 2003,
234 (http://www.ietf.org/internet-drafts/draft-josefsson-dns-
235 url-09.txt)
236
237 [5] Gulbrandsen, A., Vixie, P. and Esibov, L., "A DNS RR for speci‐
238 fying the location of services (DNS SRV)", RFC 2782, February
239 2000, (http://www.ietf.org/rfc/rfc2782.txt)
240
241 [6] Ohta, M. "Incremental Zone Transfer in DNS", RFC 1995, August
242 1996, (http://www.ietf.org/rfc/rfc1995.txt)
243
245 Pat Thoyts
246
248 This document, and the package it describes, will undoubtedly contain
249 bugs and other problems. Please report such in the category dns of the
250 Tcllib SF Trackers [http://sourceforge.net/tracker/?group_id=12883].
251 Please also report any ideas for enhancements you may have for either
252 package and/or documentation.
253
255 resolver(5)
256
258 DNS, domain name service, resolver, rfc 1034, rfc 1035, rfc 1886
259
261 Copyright (c) 2002, Pat Thoyts
262
263
264
265
266dns 1.3.3 dns(n)