What is the difference between dig +tries=x and dig +retries=x?
In cases like that, you might want to start by specifying which dig
version you are talking about, to avoid any possible ambiguities.
In my version I have only +tries
and +retry
(note singular, not plural) and the manpage line on +retry
specifically says something related to +tries
which is:
This option sets the number of times to retry UDP queries to server to T instead of the default, 2. Unlike +tries, this does not include the initial query.
If you study its source code, at https://gitlab.isc.org/isc-projects/bind9/-/blob/9c8b7a5c450d54332f25830aa47035d87490bb3a/bin/dig/dig.c for the latest version, you can see the truth even explained "simpler" than that (showing the two options act on the same variable in fact)
case 'r':
switch (cmd[1]) {
[..]
case 'e':
switch (cmd[2]) {
[..]
case 't': /* retry / retries */
[..]
result = parse_uint(&lookup->retries, value,
MAXTRIES - 1, "retries");
if (result != ISC_R_SUCCESS) {
warn("Couldn't parse retries");
goto exit_or_usage;
}
lookup->retries++;
[..]
case 't':
switch (cmd[1]) {
[..]
case 'r':
switch (cmd[2]) {
[..]
case 'i': /* tries */
[..]
result = parse_uint(&lookup->retries, value,
MAXTRIES, "tries");
if (result != ISC_R_SUCCESS) {
warn("Couldn't parse tries");
goto exit_or_usage;
}
if (lookup->retries == 0) {
lookup->retries = 1;
}
break;
So retry
(or retries
in fact) sets lookup->retries
value and then increment it, while tries
just sets the value to what was given. tries
gives the total number of attempts to do, while retry
gives the amount of attempts to do after a first failure, so the total amount of attempts is that plus one.
Same thing, just different API/semantic.
FWIW, lookup->retries
is initialized elsewhere (before the above) like that:
int tries = 3;
[..]
*looknew = (dig_lookup_t){
[..]
.retries = tries,
That 3
explains the 2
in the man page as that 2
is the number of retries, so after the first try, hence total of tries by default would be 3. Yes, I do think all of this to be quite convoluted for something trivial :-)