8 Replies Latest reply: Aug 25, 2012 9:32 PM by stleadershipboard
stleadershipboard Level 1 Level 1 (0 points)

Hi,

 

I need to make the hosts file top priority in lookups.  Could someone advise me on whether or not the following procedure will work?  Do I need to do anything else to make the hosts file itself top priority or is that implied in "strict unicast ordering"?  I'm using OS X 10.6.8 right now.  If there is a better way to do it, let me know!

 

 

Open the com.apple.mDNSResponder.plist file in a text editor (the file is located in /System/Library/LaunchDaemons/ ).

Locate the following key in the file:

<key>EnableTransactions</key>
      <true/>
</dict>


Between the last <true/> and </dict>, add the following lines:

<key>StrictUnicastOrdering</key>
     <true/>


Use Terminal to unload and load mDNSResponder.

 

Thanks

 

Bob


Mac OS X (10.6.8)
  • Linc Davis Level 10 Level 10 (147,490 points)

    The hosts file has priority in name resolution by default.

  • stleadershipboard Level 1 Level 1 (0 points)

    (in response to Linc Davis)

     

    I would think it does, but very occasionally a request slips through and is resolved by DNS to an external webpage instead.  Is there any way to check on the order (is there a modern equivalent to "lookupd -configuration" or something like it)?  I know the order is supposed to be dynamic now...

     

    I just had a thought -- a slow-responding server is pushed to the last position in the lookup order according to Apple (brief summary, in case someone reading hasn't yet seen it: http://support.apple.com/kb/HT4030).  Maybe when the computer has a heavy load to process, and it takes longer than the 30 second timeout to read the hosts file, it goes on - by default - to the next-in-line resolution option.  Does that seem plausible?  As a side note, I do remember to flush the cache when I edit the hosts file.

  • Linc Davis Level 10 Level 10 (147,490 points)

    The only way I know that the hosts file might be overriden is by the DirectoryServices database. If you get something from "dscl . list hosts" that conflicts with the hosts file, that would be it.

  • stleadershipboard Level 1 Level 1 (0 points)

    I checked and got this from Terminal:

    BSD
    Local

    Contact
    Search

    Wouldn't that mean it is in fact second to DNS lookups, or is there something I don't know that's going on?

  • Linc Davis Level 10 Level 10 (147,490 points)

    I don't know what that's the output from, but it seems to have nothing to do with name resolution.

  • stleadershipboard Level 1 Level 1 (0 points)

    I don't know what that's the output from, but it seems to have nothing to do with name resolution.

    I should have been clearer:  In a Terminal window, I opened dscl (in interactive mode) and entered "list . hosts" just like you said.  BSD shows up before Local, which says to me that DNS will be searched before the hosts file (so I won't get the result I want that's given in the hosts file).  Tell me if I'm incorrect there, though.  Is there any way to read the cache results directly?  That would really help, but I haven't found out how to do that yet or if it's possible.  Thanks for your help so far!

     

    Bob

  • Linc Davis Level 10 Level 10 (147,490 points)

    I opened dscl (in interactive mode) and entered "list . hosts" just like you said.

     

    That's not what I said.

     

    dscl . list hosts

  • stleadershipboard Level 1 Level 1 (0 points)

    Okay, this is what I entered and what returned:

    ~$  dscl . list hosts
    list: Invalid Path
    <dscl_cmd> DS Error: -14009 (eDSUnknownNodeName)
    ~$

    Do you know what it means?  If it's too complicated/too long to explain, is there any way to read or at least get a result back from the cache?