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.0?
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
135 ::dns::name token
136 Returns a list of all domain names returned as an answer to your
137 query.
138
139
140 ::dns::address token
141 Returns a list of the address records that match your query.
142
143
144 ::dns::cname token
145 Returns a list of canonical names (usually just one) matching
146 your query.
147
148
149 ::dns::result token
150 Returns a list of all the decoded answer records provided for
151 your query. This permits you to extract the result for more
152 unusual query types.
153
154
155 ::dns::status token
156 Returns the status flag. For a successfully completed query this
157 will be ok. May be error or timeout or eof. See also
158 ::dns::error
159
160
161 ::dns::error token
162 Returns the error message provided for requests whose status is
163 error. If there is no error message then an empty string is
164 returned.
165
166
167 ::dns::reset token
168 Reset or cancel a DNS query.
169
170
171 ::dns::wait token
172 Wait for a DNS query to complete and return the status upon com‐
173 pletion.
174
175
176 ::dns::cleanup token
177 Remove all state variables associated with the request.
178
179
180 ::dns::nameservers
181 Attempts to return a list of the nameservers currently config‐
182 ured for the users system. On a unix machine this parses the
183 /etc/resolv.conf file for nameservers (if it exists) and on Win‐
184 dows systems we examine certain parts of the registry. If no
185 nameserver can be found then the loopback address (127.0.0.1) is
186 used as a default.
187
189 % set tok [dns::resolve www.tcl.tk]
190 ::dns::1
191 % dns::status $tok
192 ok
193 % dns::address $tok
194 199.175.6.239
195 % dns::name $tok
196 www.tcl.tk
197 % dns::cleanup $tok
198
199
200 Using DNS URIs as queries:
201
202 % set tok [dns::resolve "dns:tcl.tk;type=MX"]
203 % set tok [dns::resolve "dns://l.root-servers.net/www.tcl.tk"]
204
205
206 Reverse address lookup:
207
208 % set tok [dns::resolve 127.0.0.1]
209 ::dns::1
210 % dns::name $tok
211 localhost
212 % dns::cleanup $tok
213
214
216 [1] Mockapetris, P., "Domain Names - Concepts and Facilities", RFC
217 1034, November 1987. (http://www.ietf.org/rfc/rfc1034.txt)
218
219 [2] Mockapetris, P., "Domain Names - Implementation and Specifica‐
220 tion", RFC 1035, November 1087.
221 (http://www.ietf.org/rfc/rfc1035.txt)
222
223 [3] Thompson, S. and Huitema, C., "DNS Extensions to support IP ver‐
224 sion 6", RFC 1886, December 1995.
225 (http://www.ietf.org/rfc/rfc1886.txt)
226
227 [4] Josefsson, S., "Domain Name System Uniform Resource Identi‐
228 fiers", Internet-Draft, October 2003,
229 (http://www.ietf.org/internet-drafts/draft-josefsson-dns-
230 url-09.txt)
231
232 [5] Gulbrandsen, A., Vixie, P. and Esibov, L., "A DNS RR for speci‐
233 fying the location of services (DNS SRV)", RFC 2782, February
234 2000, (http://www.ietf.org/rfc/rfc2782.txt)
235
236 [6] Ohta, M. "Incremental Zone Transfer in DNS", RFC 1995, August
237 1996, (http://www.ietf.org/rfc/rfc1995.txt)
238
240 Pat Thoyts
241
243 resolver(5)
244
246 DNS, domain name service, resolver, rfc 1034, rfc 1035, rfc 1886
247
249 Copyright (c) 2002, Pat Thoyts
250
251
252
253
254dns 1.3.0 dns(n)