Cross-platform way to retrieve the current (Operative system) DNS server IP address in python

DarkBlue pict100 at
Sat Apr 24 09:50:40 EDT 2010

On Apr 22, 4:55 pm, joamag <joa... at> 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
    m ="(([0-9]+\.){3}[0-9]+)", External_IP)
    return my_IP

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

this gets you your ip address

hope it helps.

More information about the Python-list mailing list