Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Command line to get my public IP address by leveraging handy feature in OpenDNS
# OpenDNS resolves "" to the caller's publicly-facing IP.
# To use this feature, resolve that DNS name against an OpenDNS name server.
# pip install dnspython
import dns.resolver
resolver = dns.resolver.Resolver()
opendns_ns_ip = resolver.query('')
resolver.nameservers = [str(opendns_ns_ip[0])]
my_ip = resolver.query('')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment