Linux / Ubuntu lookup domain / nslookup in variable

Date: 2025-01-17
# lookup address 'solidt.eu' ipv4 in nameserver 8.8.8.8 and store the result in environment variable
export MY_IP=$(dig +short @8.8.8.8 "solidt.eu" A)

$ns=8.8.8.8
$domain="solidt.eu"
export MY_IP=$(dig +short @$ns $domain A)

# bonus: store variable to file
# and load variable from file for e.g. another session 
echo "$MY_IP" > /tmp/my_ip
$MY_IP=$(cat /tmp/my_ip)
92390cookie-checkLinux / Ubuntu lookup domain / nslookup in variable