Don't use third-party "what is my IP" services (rebase)

Rebased version of  #3088. I've split the changes into two commits.

Note: this is not ready for merging yet, there are some known problems, see #3088 for discussion