#!/usr/bin/env bash LOCAL_HOSTNAME=${1} unbound-control local_data_remove ${LOCAL_HOSTNAME} > /dev/null 2>&1 for dns_lookup in $(unbound-host ${LOCAL_HOSTNAME} | grep -Po "(([0-9]+\.){3}[0-9]+|([0-9a-f]+::?)+:?[0-9a-f]+)"); do if echo ${dns_lookup} | grep -q ":"; then unbound-control local_data ${LOCAL_HOSTNAME} IN AAAA ${dns_lookup} > /dev/null 2>&1 else unbound-control local_data ${LOCAL_HOSTNAME} IN A ${dns_lookup} > /dev/null 2>&1 fi done