Skip to content

Instantly share code, notes, and snippets.

Created February 2, 2020 16:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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