1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
|
'\"
'\" Generated from file 'tcllib_dns\&.man' by tcllib/doctools with format 'nroff'
'\" Copyright (c) 2002, Pat Thoyts
'\"
.TH "dns" n 1\&.6\&.1 tcllib "Domain Name Service"
.\" The -*- nroff -*- definitions below are for supplemental macros used
.\" in Tcl/Tk manual entries.
.\"
.\" .AP type name in/out ?indent?
.\" Start paragraph describing an argument to a library procedure.
.\" type is type of argument (int, etc.), in/out is either "in", "out",
.\" or "in/out" to describe whether procedure reads or modifies arg,
.\" and indent is equivalent to second arg of .IP (shouldn't ever be
.\" needed; use .AS below instead)
.\"
.\" .AS ?type? ?name?
.\" Give maximum sizes of arguments for setting tab stops. Type and
.\" name are examples of largest possible arguments that will be passed
.\" to .AP later. If args are omitted, default tab stops are used.
.\"
.\" .BS
.\" Start box enclosure. From here until next .BE, everything will be
.\" enclosed in one large box.
.\"
.\" .BE
.\" End of box enclosure.
.\"
.\" .CS
.\" Begin code excerpt.
.\"
.\" .CE
.\" End code excerpt.
.\"
.\" .VS ?version? ?br?
.\" Begin vertical sidebar, for use in marking newly-changed parts
.\" of man pages. The first argument is ignored and used for recording
.\" the version when the .VS was added, so that the sidebars can be
.\" found and removed when they reach a certain age. If another argument
.\" is present, then a line break is forced before starting the sidebar.
.\"
.\" .VE
.\" End of vertical sidebar.
.\"
.\" .DS
.\" Begin an indented unfilled display.
.\"
.\" .DE
.\" End of indented unfilled display.
.\"
.\" .SO ?manpage?
.\" Start of list of standard options for a Tk widget. The manpage
.\" argument defines where to look up the standard options; if
.\" omitted, defaults to "options". The options follow on successive
.\" lines, in three columns separated by tabs.
.\"
.\" .SE
.\" End of list of standard options for a Tk widget.
.\"
.\" .OP cmdName dbName dbClass
.\" Start of description of a specific option. cmdName gives the
.\" option's name as specified in the class command, dbName gives
.\" the option's name in the option database, and dbClass gives
.\" the option's class in the option database.
.\"
.\" .UL arg1 arg2
.\" Print arg1 underlined, then print arg2 normally.
.\"
.\" .QW arg1 ?arg2?
.\" Print arg1 in quotes, then arg2 normally (for trailing punctuation).
.\"
.\" .PQ arg1 ?arg2?
.\" Print an open parenthesis, arg1 in quotes, then arg2 normally
.\" (for trailing punctuation) and then a closing parenthesis.
.\"
.\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
.if t .wh -1.3i ^B
.nr ^l \n(.l
.ad b
.\" # Start an argument description
.de AP
.ie !"\\$4"" .TP \\$4
.el \{\
. ie !"\\$2"" .TP \\n()Cu
. el .TP 15
.\}
.ta \\n()Au \\n()Bu
.ie !"\\$3"" \{\
\&\\$1 \\fI\\$2\\fP (\\$3)
.\".b
.\}
.el \{\
.br
.ie !"\\$2"" \{\
\&\\$1 \\fI\\$2\\fP
.\}
.el \{\
\&\\fI\\$1\\fP
.\}
.\}
..
.\" # define tabbing values for .AP
.de AS
.nr )A 10n
.if !"\\$1"" .nr )A \\w'\\$1'u+3n
.nr )B \\n()Au+15n
.\"
.if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
.nr )C \\n()Bu+\\w'(in/out)'u+2n
..
.AS Tcl_Interp Tcl_CreateInterp in/out
.\" # BS - start boxed text
.\" # ^y = starting y location
.\" # ^b = 1
.de BS
.br
.mk ^y
.nr ^b 1u
.if n .nf
.if n .ti 0
.if n \l'\\n(.lu\(ul'
.if n .fi
..
.\" # BE - end boxed text (draw box now)
.de BE
.nf
.ti 0
.mk ^t
.ie n \l'\\n(^lu\(ul'
.el \{\
.\" Draw four-sided box normally, but don't draw top of
.\" box if the box started on an earlier page.
.ie !\\n(^b-1 \{\
\h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.el \}\
\h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
.\}
.\}
.fi
.br
.nr ^b 0
..
.\" # VS - start vertical sidebar
.\" # ^Y = starting y location
.\" # ^v = 1 (for troff; for nroff this doesn't matter)
.de VS
.if !"\\$2"" .br
.mk ^Y
.ie n 'mc \s12\(br\s0
.el .nr ^v 1u
..
.\" # VE - end of vertical sidebar
.de VE
.ie n 'mc
.el \{\
.ev 2
.nf
.ti 0
.mk ^t
\h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
.sp -1
.fi
.ev
.\}
.nr ^v 0
..
.\" # Special macro to handle page bottom: finish off current
.\" # box/sidebar if in box/sidebar mode, then invoked standard
.\" # page bottom macro.
.de ^B
.ev 2
'ti 0
'nf
.mk ^t
.if \\n(^b \{\
.\" Draw three-sided box if this is the box's first page,
.\" draw two sides but no top otherwise.
.ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
.\}
.if \\n(^v \{\
.nr ^x \\n(^tu+1v-\\n(^Yu
\kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
.\}
.bp
'fi
.ev
.if \\n(^b \{\
.mk ^y
.nr ^b 2
.\}
.if \\n(^v \{\
.mk ^Y
.\}
..
.\" # DS - begin display
.de DS
.RS
.nf
.sp
..
.\" # DE - end display
.de DE
.fi
.RE
.sp
..
.\" # SO - start of list of standard options
.de SO
'ie '\\$1'' .ds So \\fBoptions\\fR
'el .ds So \\fB\\$1\\fR
.SH "STANDARD OPTIONS"
.LP
.nf
.ta 5.5c 11c
.ft B
..
.\" # SE - end of list of standard options
.de SE
.fi
.ft R
.LP
See the \\*(So manual entry for details on the standard options.
..
.\" # OP - start of full description for a single option
.de OP
.LP
.nf
.ta 4c
Command-Line Name: \\fB\\$1\\fR
Database Name: \\fB\\$2\\fR
Database Class: \\fB\\$3\\fR
.fi
.IP
..
.\" # CS - begin code excerpt
.de CS
.RS
.nf
.ta .25i .5i .75i 1i
..
.\" # CE - end code excerpt
.de CE
.fi
.RE
..
.\" # UL - underline word
.de UL
\\$1\l'|0\(ul'\\$2
..
.\" # QW - apply quotation marks to word
.de QW
.ie '\\*(lq'"' ``\\$1''\\$2
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\$2
..
.\" # PQ - apply parens and quotation marks to word
.de PQ
.ie '\\*(lq'"' (``\\$1''\\$2)\\$3
.\"" fix emacs highlighting
.el (\\*(lq\\$1\\*(rq\\$2)\\$3
..
.\" # QR - quoted range
.de QR
.ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
.\"" fix emacs highlighting
.el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
..
.\" # MT - "empty" string
.de MT
.QW ""
..
.BS
.SH NAME
dns \- Tcl Domain Name Service Client
.SH SYNOPSIS
package require \fBTcl 8\&.5 9\fR
.sp
package require \fBdns ?1\&.6\&.1?\fR
.sp
\fB::dns::resolve\fR \fIquery\fR ?\fIoptions\fR?
.sp
\fB::dns::configure\fR ?\fIoptions\fR?
.sp
\fB::dns::name\fR \fItoken\fR
.sp
\fB::dns::address\fR \fItoken\fR
.sp
\fB::dns::cname\fR \fItoken\fR
.sp
\fB::dns::result\fR \fItoken\fR
.sp
\fB::dns::status\fR \fItoken\fR
.sp
\fB::dns::error\fR \fItoken\fR
.sp
\fB::dns::reset\fR \fItoken\fR
.sp
\fB::dns::wait\fR \fItoken\fR
.sp
\fB::dns::cleanup\fR \fItoken\fR
.sp
\fB::dns::nameservers\fR
.sp
.BE
.SH DESCRIPTION
.PP
The dns package provides a Tcl only Domain Name Service client\&. You
should refer to (1) and (2) for information about the DNS protocol or
read resolver(3) to find out how the C library resolves domain names\&.
The intention of this package is to insulate Tcl scripts
from problems with using the system library resolver for slow name servers\&.
It may or may not be of practical use\&. Internet name resolution is a
complex business and DNS is only one part of the resolver\&. You may
find you are supposed to be using hosts files, NIS or WINS to name a
few other systems\&. This package is not a substitute for the C library
resolver - it does however implement name resolution over DNS\&.
The package also extends the package \fBuri\fR to support DNS URIs
(4) of the form \fIdns:what\&.host\&.com\fR or
\fIdns://my\&.nameserver/what\&.host\&.com\fR\&. The \fBdns::resolve\fR
command can handle DNS URIs or simple domain names as a query\&.
.PP
\fINote:\fR The package defaults to using DNS over TCP
connections\&. If you wish to use UDP you will need to have the
\fBtcludp\fR package installed and have a version that
correctly handles binary data (> 1\&.0\&.4)\&.
This is available at \fIhttp://tcludp\&.sourceforge\&.net/\fR\&.
If the \fBudp\fR package is present then UDP will be used by
default\&.
.PP
\fINote:\fR The package supports DNS over TLS (RFC 7858) for
enhanced privacy of DNS queries\&. Using this feature requires
the TLS package\&.
.SH COMMANDS
.TP
\fB::dns::resolve\fR \fIquery\fR ?\fIoptions\fR?
Resolve a domain name using the \fIDNS\fR protocol\&. \fIquery\fR is
the domain name to be lookup up\&. This should be either a fully
qualified domain name or a DNS URI\&.
.RS
.TP
\fB-nameserver\fR \fIhostname\fR or \fB-server\fR \fIhostname\fR
Specify an alternative name server for this request\&.
.TP
\fB-protocol\fR \fItcp|udp\fR
Specify the network protocol to use for this request\&. Can be one of
\fItcp\fR or \fIudp\fR\&.
.TP
\fB-port\fR \fIportnum\fR
Specify an alternative port\&.
.TP
\fB-search\fR \fIdomainlist\fR
.TP
\fB-timeout\fR \fImilliseconds\fR
Override the default timeout\&.
.TP
\fB-type\fR \fITYPE\fR
Specify the type of DNS record you are interested in\&. Valid values
are A, NS, MD, MF, CNAME, SOA, MB, MG, MR, NULL, WKS, PTR, HINFO,
MINFO, MX, TXT, SPF, SRV, AAAA, AXFR, MAILB, MAILA and *\&.
See RFC1035 for details about the return values\&.
See \fIhttp://spf\&.pobox\&.com/\fR about SPF\&.
See (3) about AAAA records and RFC2782 for details of SRV records\&.
.TP
\fB-class\fR \fICLASS\fR
Specify the class of domain name\&. This is usually IN but may be one
of IN for internet domain names, CS, CH, HS or * for any class\&.
.TP
\fB-recurse\fR \fIboolean\fR
Set to \fIfalse\fR if you do not want the name server to recursively
act upon your request\&. Normally set to \fItrue\fR\&.
.TP
\fB-command\fR \fIprocname\fR
Set a procedure to be called upon request completion\&. The procedure
will be passed the token as its only argument\&.
.TP
\fB-usetls\fR \fIboolean\fR
Set the \fItrue\fR to use DNS over TLS\&. This will force the use of
TCP and change the default port to 853\&. Certificate validation is
required so a source of trusted certificate authority certificates
must be provided using \fI-cafile\fR or \fI-cadir\fR\&.
.TP
\fB-cafile\fR \fIfilepath\fR
Specify a file containing a collection of trusted certificate
authority certficates\&. See the \fBupdate-ca-certificates\fR command
manual page for details or the \fB-CAfile\fR option help from
\fBopenssl\fR\&.
.TP
\fB-cadir\fR \fIdirpath\fR
Specify a directory containing trusted certificate authority
certificates\&. This must be provided if \fB-cafile\fR is not
specified for certificate validation to work when \fB-usetls\fR is
enabled\&. See the \fBopenssl\fR documentation for the required
structure of this directory\&.
.RE
.sp
.TP
\fB::dns::configure\fR ?\fIoptions\fR?
The \fB::dns::configure\fR command is used to setup the dns
package\&. The server to query, the protocol and domain search path are
all set via this command\&. If no arguments are provided then a list of
all the current settings is returned\&. If only one argument then it
must the the name of an option and the value for that option is
returned\&.
.RS
.TP
\fB-nameserver\fR \fIhostname\fR
Set the default name server to be used by all queries\&. The default is
\fIlocalhost\fR\&.
.TP
\fB-protocol\fR \fItcp|udp\fR
Set the default network protocol to be used\&. Default is \fItcp\fR\&.
.TP
\fB-port\fR \fIportnum\fR
Set the default port to use on the name server\&. The default is 53\&.
.TP
\fB-search\fR \fIdomainlist\fR
Set the domain search list\&. This is currently not used\&.
.TP
\fB-timeout\fR \fImilliseconds\fR
Set the default timeout value for DNS lookups\&. Default is 30 seconds\&.
.TP
\fB-loglevel\fR \fIlevel\fR
Set the log level used for emitting diagnostic messages from this
package\&. The default is \fIwarn\fR\&. See the \fBlog\fR package
for details of the available levels\&.
.TP
\fB-cafile\fR \fIfilepath\fR
Set the default file path to be used for the \fB-cafile\fR
option to \fBdns::resolve\fR\&.
.TP
\fB-cadir\fR \fIdirpath\fR
Set the default directory path to be used for the \fB-cadir\fR
option to \fBdns::resolve\fR\&.
.RE
.sp
.TP
\fB::dns::name\fR \fItoken\fR
Returns a list of all domain names returned as an answer to your query\&.
.sp
.TP
\fB::dns::address\fR \fItoken\fR
Returns a list of the address records that match your query\&.
.sp
.TP
\fB::dns::cname\fR \fItoken\fR
Returns a list of canonical names (usually just one) matching your query\&.
.sp
.TP
\fB::dns::result\fR \fItoken\fR
Returns a list of all the decoded answer records provided for your
query\&. This permits you to extract the result for more unusual query types\&.
.sp
.TP
\fB::dns::status\fR \fItoken\fR
Returns the status flag\&. For a successfully completed query this will be
\fIok\fR\&. May be \fIerror\fR or \fItimeout\fR or \fIeof\fR\&.
See also \fB::dns::error\fR
.sp
.TP
\fB::dns::error\fR \fItoken\fR
Returns the error message provided for requests whose status is \fIerror\fR\&.
If there is no error message then an empty string is returned\&.
.sp
.TP
\fB::dns::reset\fR \fItoken\fR
Reset or cancel a DNS query\&.
.sp
.TP
\fB::dns::wait\fR \fItoken\fR
Wait for a DNS query to complete and return the status upon completion\&.
.sp
.TP
\fB::dns::cleanup\fR \fItoken\fR
Remove all state variables associated with the request\&.
.sp
.TP
\fB::dns::nameservers\fR
Attempts to return a list of the nameservers currently configured
for the users system\&. On a unix machine this parses the
/etc/resolv\&.conf file for nameservers (if it exists) and on Windows
systems we examine certain parts of the registry\&. If no nameserver can
be found then the loopback address (127\&.0\&.0\&.1) is used as a default\&.
.PP
.SH EXAMPLES
.PP
.CS
% set tok [dns::resolve www\&.tcl\&.tk]
::dns::1
% dns::status $tok
ok
% dns::address $tok
199\&.175\&.6\&.239
% dns::name $tok
www\&.tcl\&.tk
% dns::cleanup $tok
.CE
.PP
Using DNS URIs as queries:
.CS
% set tok [dns::resolve "dns:tcl\&.tk;type=MX"]
% set tok [dns::resolve "dns://l\&.root-servers\&.net/www\&.tcl\&.tk"]
.CE
.PP
Reverse address lookup:
.CS
% set tok [dns::resolve 127\&.0\&.0\&.1]
::dns::1
% dns::name $tok
localhost
% dns::cleanup $tok
.CE
.PP
Using DNS over TLS (RFC 7858):
.CS
% set tok [dns::resolve www\&.tcl\&.tk -nameserver dns-tls\&.bitwiseshift\&.net -usetls 1 -cafile /etc/ssl/certs/ca-certificates\&.crt]
::dns::12
% dns::wait $tok
ok
% dns::address $tok
104\&.25\&.119\&.118 104\&.25\&.120\&.118
.CE
.SH REFERENCES
.IP [1]
Mockapetris, P\&., "Domain Names - Concepts and Facilities",
RFC 1034, November 1987\&.
(\fIhttp://www\&.ietf\&.org/rfc/rfc1034\&.txt\fR)
.IP [2]
Mockapetris, P\&., "Domain Names - Implementation and Specification",
RFC 1035, November 1087\&.
(\fIhttp://www\&.ietf\&.org/rfc/rfc1035\&.txt\fR)
.IP [3]
Thompson, S\&. and Huitema, C\&., "DNS Extensions to support IP version 6",
RFC 1886, December 1995\&.
(\fIhttp://www\&.ietf\&.org/rfc/rfc1886\&.txt\fR)
.IP [4]
Josefsson, S\&., "Domain Name System Uniform Resource Identifiers",
Internet-Draft, October 2003,
(\fIhttp://www\&.ietf\&.org/internet-drafts/draft-josefsson-dns-url-09\&.txt\fR)
.IP [5]
Gulbrandsen, A\&., Vixie, P\&. and Esibov, L\&.,
"A DNS RR for specifying the location of services (DNS SRV)",
RFC 2782, February 2000,
(\fIhttp://www\&.ietf\&.org/rfc/rfc2782\&.txt\fR)
.IP [6]
Ohta, M\&. "Incremental Zone Transfer in DNS",
RFC 1995, August 1996,
(\fIhttp://www\&.ietf\&.org/rfc/rfc1995\&.txt\fR)
.IP [7]
Hu, Z\&., etc al\&.
"Specification for DNS over Transport Layer Security (TLS)",
RFC 7858, May 2016,
(\fIhttp://www\&.ietf\&.org/rfc/rfc7858\&.txt\fR)
.PP
.SH AUTHORS
Pat Thoyts
.SH "BUGS, IDEAS, FEEDBACK"
This document, and the package it describes, will undoubtedly contain
bugs and other problems\&.
Please report such in the category \fIdns\fR of the
\fITcllib Trackers\fR [http://core\&.tcl\&.tk/tcllib/reportlist]\&.
Please also report any ideas for enhancements you may have for either
package and/or documentation\&.
.PP
When proposing code changes, please provide \fIunified diffs\fR,
i\&.e the output of \fBdiff -u\fR\&.
.PP
Note further that \fIattachments\fR are strongly preferred over
inlined patches\&. Attachments can be made by going to the \fBEdit\fR
form of the ticket immediately after its creation, and then using the
left-most button in the secondary navigation bar\&.
.SH "SEE ALSO"
resolver(5)
.SH KEYWORDS
DNS, domain name service, resolver, rfc 1034, rfc 1035, rfc 1886, rfc 7858
.SH CATEGORY
Networking
.SH COPYRIGHT
.nf
Copyright (c) 2002, Pat Thoyts
.fi
|