Is there a way in Python to check if the public IP was changed without external request?

Viewed 44

So I have a bot on Python that check some data in the cycle. There is a public IP check at the start of the code:

ip = get('https://api.ipify.org').text

I need to check if the public IP was changed by any means (e.g. VPN) in the beginning of every cycle WITHOUT external request. Is it possible by any way?

1 Answers

try this

import os
import urllib2

def check_in():
    fqn = os.uname()[1]
    ext_ip = urllib2.urlopen('http://whatismyip.org').read()
    print("Asset: %s " % fqn, "Checking in from IP#: %s " % ext_ip)
Related