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

Tiago Katcipis tiagokatcipis at gmail.com
Wed Apr 28 01:45:59 CEST 2010


maybe this helps you:

http://pypi.python.org/pypi/netifaces/0.3

best regards,
Katcipis

On Tue, Apr 27, 2010 at 7:49 PM, joamag <joamag at gmail.com> wrote:

> On 24 Abr, 14:50, DarkBlue <pict... at gmail.com> wrote:
> > On Apr 22, 4:55 pm, joamag <joa... at 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(<http://checkip.dyndns.com/%27%29.read%28>
> )
> >     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.
>
> Hi,
>
> It's not my ip address that I want to discover... I want to discover
> my default dns server ip address.
> This ip is stored in an operative system basis.
>
> Dos anyone know how to get it ?
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100427/91de85d6/attachment.html>


More information about the Python-list mailing list