ZDNS should accept `dig`-like input
spencerdrak opened this issue · 2 comments
It appears (via digging through git history) that ZDNS at one point supported the following:
./zdns A example.com
However, this usage currently is not functional, as it performs no lookup and instead just blocks and waits for STDIN as the tool usually does.
This ticket involves re-creating the functionality to perform a dig-like lookup.
Hi, I don't know if this is still relevant as I haven't gotten as far as testing this yet. 😅 But I made a small wrapper in shell script that does exactly what you're asking for.
#!/bin/bash
args=("$@")
zdns=/PATH/TO/ZDNS/zdns
index=0
for ((i=0; i<${#args[@]}; i++)); do
index=$i
done
host="${args[$index]}"
unset 'args[$index]'
nargs=("${args[@]}")
echo $host | $zdns "${nargs[@]}"
It takes the very last argument, strips it from the rest, then adds it to the preceding echo command.
Remember to edit the path to the zdns
binary inside the script, then saved it as f.ex zdns-wrapper.sh
and use chmod +x
.
The folder containing the zdns
binary should then be removed from the $PATH
variable if it is included, and a symlink to the wrapper should be added to any folder included in $PATH
with sudo ln -s /PATH/TO/WRAPPER/zdns-wrapper.sh /PATH/TO/$PATH/zdns
.
If you can't remove the $PATH to the zdns
binary, then add an export PATH=/PATH/TO/WRAPPER:$PATH
in your .bashrc
or your shells variant, so it takes precedence and runs when you type zdns
.
It should accept both strings and filenames, if used with "string"
or filename
syntax respectively.
Now you can use it like dig with zdns A --all-nameservers "google.com"
.