I’ve been incredibly frustrated by how poorly DNS resolves since upgrading first to Lion, then later to Mountain Lion (on a new machine, but migrating my old files). The impact of this was particularly bad connecting to SMB/CIFS/Samba shares – some would mount after several minutes, others not at all.
Early on it became clear the problems were related to my router (DDWRT) not supporting IPv6 but then neither does my ISP. Here are a few things to try:
DNS Resolver Order
Normally /etc/hosts is first in line for DNS resolution. But it seems improper line termination, presumably a carriage return/linefeed instead of just a linefeed, causes all sorts of problems. Many posts describe ways to force reloading of the hosts file, but the root cause seems to be improper line termination. Always make sure you use a Unix compatible editor.
To check the order resolvers are called:
These two were the main source of my problems:
1. My host has multiple names – these must all be present, and fully qualified:
127.0.0.1 hosta hosta.foo.com
127.0.0.1 hostb hostb.foo.com
2. All localhost entries must have ::1 entries too, or OS X will send IPv6 requests to resolve them externally. And this despite IPv6 being disabled on the interface!
::1 hosta hosta.foo.com
::1 hostb hostb.foo.com
Turn off IPv6 in Network Preferences
Go to System Preferences -> Network -> Advanced -> TCP. In the Configure IPv6 list, you may have an “Off” option. If so, select it. If not, see next tip.
Turn off IPv6 from Terminal
List available network services:
Turn off IPv6 on chosen device (name from above list):
networksetup -setv6off your_device_name (i.e. Wi-Fi, Ethernet)
Now the Configure IPv6 list for that device will show “Off” (see previous tip).
Apparently older OS X installations migrated to newer releases may still have hooks to no-longer existant MobileMe servers. Many users report that removing these greatly speeds up SMB connection. The following removes those references if present and are harmless if not.
defaults delete -g iToolsMemberDomain
defaults delete -g iToolsMember