OS X not resolving hostnames for SSH/HTTP

Posted on


I have a Debian server named neptune, with a static IP of which provides SMB, Intranet and SSH services. On my Windows computer it resolves fine, yet on my Mac it appears under “Shared” with its hostname and I am able to use it. However, I can’t use the hostname to SSH into it, nor can I go to it by hostname in my browser. I’ve tried restarting my Mac and renewing its IP address, but it’s not been successful.


You’re lacking basic skills on networks. To connect to something with it’s name you need a DNS Server and registered IP addresses in this DNS Server.

What you’re seeing is nothing more than a mess of protocols broadcasting in your network with different names and domain names.

In common sense, perhaps you’re missing the local domain. Yep. Try to connect to the hostname you like with an ending .local; for example: if your hostname is machine try ssh to machine.local.

Why I think that’s the problem? Because you said that you have a Debian Server with SMB and extra services, so it might have Avahi installed, and Avahi commonly broadcast a .local domain. For more info take a look over here: http://avahi.org/wiki/AvahiAndUnicastDotLocal

EDIT: Since you’re running a DNS server you must populate your DNS with records from your network. I don’t know what DNS domain zone you’ve defined but you must put a record in this way, considering you’re running BIND:        IN        A        neptune

After this double check if all your machines are using your DNS Server. In the Windows and OS X machines it’s located on the Network Preferences. Just put your DNS Server as primary and another one, commonly from your ISP, as a failover DNS.

Then you should try to connect to neptune.yourdomain.com and see if you get the expected results.

If not, start the debugging processes with nslookup and dig tools. One common thing that happens in failing DNS resolution is bad caches, this happens a lot on OS X machines, even in my machine this happens. So I’m constantly issuing this command on the terminal to cleanup the caches:

sudo killall mDNSResponder

Let’s see if your problem is solved now.

As far as I know, this is normal behaviour. If you want to make it work, you could set up your own DNS server, or add an entry to your hosts file. The latter option is the easiest, all you need to do is add the following to /private/etc/hosts.  neptune

You should be able to edit it with the command sudo nano /private/etc/hosts

I had previously (very recently, since last startup) been able to ssh to the Mac (from my Ubuntu box).

I would get the ip on the mac via:

ifconfig -a | grep -iw inet

“Normally”, I would obtain a valid ip address that agrees with the one listed in the “sharing” system preference for remote login.

but this time I got only (i.e. localhost), and the system preference listed only a host name that I could not reach.

I rebooted, and after that I could obtain a usable ip address. I was then able to ssh to the usable ip address. (to the hostname also :-).

While I would have loved to have scripted my way through routing tables and firewalls, and maybe debug the OS X Kernel, I finally just scp’d the file.

I did draw the line, in this case, at using scp rather than a thumb drive. I have my pride (:-).

Leave a Reply

Your email address will not be published. Required fields are marked *