On Apr 22, 4:55 pm, joamag <joa...@gmail.com> wrote:
> Does anybody know a cross platform way to retrieve the default DNS
> server IP address in python ?
>
> Thanks !
> João


import os,urllib2,re


def getIpAddr():
    """
    Function for parsing external ip adress by pinging dyndns.com
    """
    External_IP=urllib2.urlopen('http://checkip.dyndns.com/').read()
    m = re.search(r"(([0-9]+\.){3}[0-9]+)", External_IP)
    my_IP= m.group(1)
    return my_IP




print('Current Ip from DynDns :  %s ') % getIpAddr()



this gets you your ip address

hope it helps.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to