Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: making socket.getaddrinfo use cached dns

Reply
Thread Tools

Re: making socket.getaddrinfo use cached dns

 
 
Chris Angelico
Guest
Posts: n/a
 
      07-07-2011
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth <(E-Mail Removed)> wrote:
> I use cached dns lookups with pdnsd on my ubuntu machine to speed up web
> access as regular lookups can take 15-30 seconds. However, python's
> mechanize and urllib etc use socket.getaddrinfo, which seems not to be using
> dns cacheing or taking a long time because of ipv6 lookups. In either case,
> I subsequent access to the same site to be fast and not require lengthy
> calls to getaddrinfo. How can I get python to correctly use cached dns
> lookups and ipv4 only (at least in those cases where it is appropriate).


One solution would be to do your own DNS lookups and then pass urllib
an IP address. Is pdnsd set up to be your computer's primary resolver?
(Is /etc/resolv.conf pointing to localhost?) If not, that might help.
I've generally done my DNS caching using BIND, so I can't help with
pdnsd specifically.

ChrisA
 
Reply With Quote
 
 
 
 
Nobody
Guest
Posts: n/a
 
      07-08-2011
On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth <(E-Mail Removed)> wrote:

>> I use cached dns lookups with pdnsd on my ubuntu machine to speed up
>> web access as regular lookups can take 15-30 seconds. However, python's
>> mechanize and urllib etc use socket.getaddrinfo, which seems not to be
>> using dns cacheing or taking a long time because of ipv6 lookups. In
>> either case, I subsequent access to the same site to be fast and not
>> require lengthy calls to getaddrinfo. How can I get python to correctly
>> use cached dns lookups and ipv4 only (at least in those cases where it
>> is appropriate).


To only query IPv4 addresses, pass socket.AF_INET as the third argument
(family) to socket.getaddrinfo(). The default is AF_UNSPEC (= 0), which
will return both IPv4 and IPv6 addresses.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PIX 501 relay client DNS requests out to an internet DNS server? nicough@gmail.com Cisco 1 11-18-2006 03:29 PM
DNS query to internal DNS server from static NAT host none Cisco 5 04-25-2006 03:11 AM
DNS query from outside to internal, public DNS server Lars Bonnesen Cisco 9 04-08-2006 11:16 AM
my cached dataset just wont stay cached!! Craig G ASP .Net 0 03-07-2005 10:02 AM
DNS question - reverse DNS getting cluttered Jose Padilla Computer Support 0 01-21-2004 10:29 PM



Advertisments