I found a way to get public ip using DNS. Source: https://dev.to/adityathebe/a-handy-way-to-know-your-public-ip-address-with-dns-servers-4nmn
Working examples:
dig +short @2606:4700:4700::1111 -6 ch txt whoami.cloudflare
dig @ns1.google.com TXT o-o.myaddr.l.google.com +short
dig +short AAAA myip.opendns.com @resolver1.opendns.com
Is there a way to determine the same using DoH/DoT?