From: Nicolas Boisselier Date: Fri, 30 Sep 2016 10:21:12 +0000 (+0100) Subject: resolve X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=6925594dd7464b95a96d90067ab508c6e82ad58a;p=nb.git resolve --- diff --git a/etc/profile.d/net.sh b/etc/profile.d/net.sh index f0f5496d..c4c6c79f 100644 --- a/etc/profile.d/net.sh +++ b/etc/profile.d/net.sh @@ -1,3 +1,16 @@ +resolve() { + ( + if [ -t 0 ]; then + while [ $# -gt 0 ]; do + printf '%s\n' "$1" + shift + done + else + cat + fi + ) | perl -MSocket -pe 's/(\b)(\d+(?:\.\d+){3})(\b)/$1.gethostbyaddr(inet_aton($2),AF_INET).$3/ge;' +} + mask2cdr () { # Assumes there's no "255." after a non-255 byte in the mask