From 1a759dde071aa48f5a501a46f52c045e8e21b610 Mon Sep 17 00:00:00 2001 From: m8in Date: Sat, 26 Sep 2026 23:42:59 +0200 Subject: [PATCH] using host and added testified --- script/host/net/printOwnIPv4Adress.sh | 27 ++++++++++++++++++++---- script/host/net/printOwnIPv6Adress.sh | 30 ++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/script/host/net/printOwnIPv4Adress.sh b/script/host/net/printOwnIPv4Adress.sh index 2ef9cfa..9702f63 100755 --- a/script/host/net/printOwnIPv4Adress.sh +++ b/script/host/net/printOwnIPv4Adress.sh @@ -44,15 +44,29 @@ function published() { _BOOT_HOSTNAME="$(hostname -b)" readonly _BOOT_HOSTNAME - nslookup -type=A "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ - | grep -A2 -i "${_BOOT_HOSTNAME}" \ + host -t a "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ + | grep -A3 -i "${_BOOT_HOSTNAME}" \ + | grep -A2 -i 'has' \ + | grep -A1 -i 'address' \ + | tail -n1 +} + +# Maybe use "resolvectl status" to get DNS Server and specify 'nslookup' +function testified() { + local _BOOT_HOSTNAME + _BOOT_HOSTNAME="$(hostname -b)" + readonly _BOOT_HOSTNAME + + host -t a "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" 8.8.8.8 | xargs -n 1 \ + | grep -A3 -i "${_BOOT_HOSTNAME}" \ + | grep -A2 -i 'has' \ | grep -A1 -i 'address' \ | tail -n1 } function verified() { local _PUBLISHED_IP - _PUBLISHED_IP="$(published)" + _PUBLISHED_IP="$(testified)" readonly _PUBLISHED_IP [ -z "${_PUBLISHED_IP}" ] \ @@ -67,7 +81,8 @@ function usage() { echo " --routed : prints the IPv4 address used to send traffic to the default gateway" echo " --public : prints all IPv4 addresses direct accessable from the internet" echo " --published : prints the IPv4 address provided by DNS using this host's name" - echo " --verified : prints the IPv4 included in 'all' und respended by 'published'" + echo " --testified : prints the IPv4 address provided by DNS using this host's name and the external DNS server 8.8.8.8" + echo " --verified : prints the IPv4 included in 'all' und respended by 'testified'" } @@ -91,6 +106,10 @@ function main(){ published return 0 ;; + --testified) + testified + return 0 + ;; --verified) verified return 0 diff --git a/script/host/net/printOwnIPv6Adress.sh b/script/host/net/printOwnIPv6Adress.sh index 4dfd7db..011770d 100755 --- a/script/host/net/printOwnIPv6Adress.sh +++ b/script/host/net/printOwnIPv6Adress.sh @@ -45,15 +45,30 @@ function published() { _BOOT_HOSTNAME="$(hostname -b)" readonly _BOOT_HOSTNAME - nslookup -type=AAAA "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ - | grep -A2 -i "${_BOOT_HOSTNAME}" \ - | grep -A1 -i address \ + host -t aaaa "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ + | grep -A4 -i "${_BOOT_HOSTNAME}" \ + | grep -A3 -i 'has' \ + | grep -A2 -i 'IPv6' \ + | grep -A1 -i 'address' \ + | tail -n1 +} + +function testified() { + local _BOOT_HOSTNAME + _BOOT_HOSTNAME="$(hostname -b)" + readonly _BOOT_HOSTNAME + + host -t aaaa "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" 2001:4860:4860::8888 | xargs -n 1 \ + | grep -A4 -i "${_BOOT_HOSTNAME}" \ + | grep -A3 -i 'has' \ + | grep -A2 -i 'IPv6' \ + | grep -A1 -i 'address' \ | tail -n1 } function verified() { local _PUBLISHED_IP - _PUBLISHED_IP="$(published)" + _PUBLISHED_IP="$(testified)" readonly _PUBLISHED_IP [ -z "${_PUBLISHED_IP}" ] \ @@ -68,7 +83,8 @@ function usage() { echo " --routed : prints the IPv6 address used to send traffic to the default gateway" echo " --public : prints all IPv6 addresses direct accessable from the internet" echo " --published : prints the IPv6 address provided by DNS using this host's name" - echo " --verified : prints the IPv6 included in 'all' und respended by 'published'" + echo " --testified : prints the IPv4 address provided by DNS using this host's name and the external DNS server 2001:4860:4860::8888" + echo " --verified : prints the IPv6 included in 'all' und respended by 'testified'" } @@ -92,6 +108,10 @@ function main(){ published return 0 ;; + --testified) + testified + return 0 + ;; --verified) verified return 0