using host and added testified

This commit is contained in:
m8in committed 2026-09-26 23:42:59 +02:00
1 parent 1dd5b3b4d2
commit 1a759dde07
2 files changed
+48 -9

No files matched your search

+23 -4
View File
@@ -44,15 +44,29 @@ function published() {
_BOOT_HOSTNAME="$(hostname -b)" _BOOT_HOSTNAME="$(hostname -b)"
readonly _BOOT_HOSTNAME readonly _BOOT_HOSTNAME
nslookup -type=A "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ host -t a "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \
| grep -A2 -i "${_BOOT_HOSTNAME}" \ | 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' \ | grep -A1 -i 'address' \
| tail -n1 | tail -n1
} }
function verified() { function verified() {
local _PUBLISHED_IP local _PUBLISHED_IP
_PUBLISHED_IP="$(published)" _PUBLISHED_IP="$(testified)"
readonly _PUBLISHED_IP readonly _PUBLISHED_IP
[ -z "${_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 " --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 " --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 " --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 published
return 0 return 0
;; ;;
--testified)
testified
return 0
;;
--verified) --verified)
verified verified
return 0 return 0
+25 -5
View File
@@ -45,15 +45,30 @@ function published() {
_BOOT_HOSTNAME="$(hostname -b)" _BOOT_HOSTNAME="$(hostname -b)"
readonly _BOOT_HOSTNAME readonly _BOOT_HOSTNAME
nslookup -type=AAAA "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \ host -t aaaa "${_BOOT_HOSTNAME:?"Missing BOOT_HOSTNAME"}" | xargs -n 1 \
| grep -A2 -i "${_BOOT_HOSTNAME}" \ | grep -A4 -i "${_BOOT_HOSTNAME}" \
| grep -A1 -i address \ | 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 | tail -n1
} }
function verified() { function verified() {
local _PUBLISHED_IP local _PUBLISHED_IP
_PUBLISHED_IP="$(published)" _PUBLISHED_IP="$(testified)"
readonly _PUBLISHED_IP readonly _PUBLISHED_IP
[ -z "${_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 " --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 " --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 " --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 published
return 0 return 0
;; ;;
--testified)
testified
return 0
;;
--verified) --verified)
verified verified
return 0 return 0