(actually the CIDR without the mask)
ip addr show eth0 | grep -oP '(?<=inets)d+(.d+){3}'
get interface
route ls /sys/class/net
ip addr list
then get ip, eg if interface is eth0
ip addr show eth0 | grep -oP '(?<=inets)d+(.d+){3}' ip addr show enp62s0u1 | grep inet | awk '{print $2}' | sed 's//[0-9]+//' ip addr show enp62s0u1 | grep inet6 | awk '{print $2}' | sed 's//[0-9]+//'
dig $(hostname).localdomain +short)