Find the answer to your Linux question:
Results 1 to 5 of 5
I have two questions on the linux (DNS) resolver library, any help appreciated. 1. DNS client queries are handled via the resolver library. Does this involve any form of queuing ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Posts
    2

    resolver library (DNS)


    I have two questions on the linux (DNS) resolver library, any help appreciated.

    1. DNS client queries are handled via the resolver library. Does this involve any form of queuing or caching in the local host? I have sniffed my connection and it seems a new query goes out for each call to gethostbyname(). Is this always the case? Is it guaranteed that the client will use this result or could it be given a result from a local cache in the operating system?

    2. is there any way to force gethostbyname() to use a particular DNS server rather than what's in resolv.conf?

    Thankyou.

  2. #2
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682

    Re: resolver library (DNS)

    Quote Originally Posted by Mudhoney
    1. DNS client queries are handled via the resolver library. Does this involve any form of queuing or caching in the local host? I have sniffed my connection and it seems a new query goes out for each call to gethostbyname(). Is this always the case? Is it guaranteed that the client will use this result or could it be given a result from a local cache in the operating system?
    Linux does not default to caching DNS entries. You may, however, install some DNS caching servers such as dnrd or pdnsd.

    Quote Originally Posted by Mudhoney
    2. is there any way to force gethostbyname() to use a particular DNS server rather than what's in resolv.conf?
    Change the nameservers in resolv.conf.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  3. #3
    Just Joined!
    Join Date
    Jun 2005
    Posts
    2
    Thanks, sarumont. I should explain that the reason I'm asking is that I've written a client that tests latency of a DNS server by querying it at a configurable interval. My client constructs a UDP packet in the correct format and sends it to the DNS. I did it this way specifically to avoid any caching or funny behaviour in resolver libraries.

    I would now like to write a version of the client using gethostbyname() or similar. The point is that I am running many instances of this client on the one host to test various different DNS hosts in our network. I therefore need to be able to tell each instance of my client which DNS to use.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru sarumont's Avatar
    Join Date
    Apr 2003
    Location
    /dev/urandom
    Posts
    3,682
    Quote Originally Posted by Mudhoney
    Thanks, sarumont. I should explain that the reason I'm asking is that I've written a client that tests latency of a DNS server by querying it at a configurable interval. My client constructs a UDP packet in the correct format and sends it to the DNS. I did it this way specifically to avoid any caching or funny behaviour in resolver libraries.

    I would now like to write a version of the client using gethostbyname() or similar. The point is that I am running many instances of this client on the one host to test various different DNS hosts in our network. I therefore need to be able to tell each instance of my client which DNS to use.
    Awesome. Feel free to post your testing results.
    "Time is an illusion. Lunchtime, doubly so."
    ~Douglas Adams, The Hitchhiker's Guide to the Galaxy

  6. #5
    Just Joined!
    Join Date
    Feb 2006
    Location
    Pittsburgh
    Posts
    32

    How does the resolver work in Linux?

    SO when a browser wants to pull up any random webpage, google.com for example, the first thing the browser needs to do is translate the dns name into an IP address in order to pass it down the stack. The name resolution on a windows box starts with the local resolver, which not only maintains a cache of it's own, but has the hosts file pre-loaded into the cache.

    If the linux local resolver does not have a cache, I was wondering how it interacts with the hosts file, if at all. Is the process similar in linux?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •