Hostname resolving problem

I would like to access Windows and Linux computers and VMs using hostnames, instead of IPs.

I can't even ping them using hostnames, even when I add ".local".

.local is also configured in the "search domains" in the network configuration (system preferences).

I don't want to use the hosts file.

How do I fix this??


Thanks!

OS X Mavericks (10.9.2)

Posted on Mar 14, 2014 6:00 PM

Reply
9 replies

Mar 14, 2014 6:57 PM in response to eranj

Bonjour (including .local) names need to be 'broadcasted' to everything on the same subnet. My guess is that the VM's are using NAT or bridging networking that effectively means they are on another subnet. The broadcast messages generally don't make it over to another subnet.

It's unclear to me how the details of routing is setup on the various VM installations, so you will need to check their manuals or forums. I suspect you will need to change them to use the same local network range.


For testing you should use 'bonjour browser' because some low level tools like ping may not use bonjour to lookup names. The site looks a little empty, but the app is good at showing you what service are being broadcasted to your network connections. When you finally get the VM config correct you should see the services appear.

http://tildesoft.com


There are other command line tools for looking at & creating bonjour records. Try 'man dns-sd' if you want to manually create local records for the machines (it's a hack, but sometimes they can get you through the day 🙂)



FYI I also find this useful when thinking about bonjour…

http://www.dns-sd.org/

Mar 14, 2014 8:18 PM in response to eranj

eranj wrote:


I don't understand why the computers are shown in finder, but I can't ping them using hostnames.

It only works with IP address.


As I mentioned earlier certain low level tools do not use bonjour to resolve 🙂.


DNS is the best & most reliable way to make networking work via names, but you would need a local DNS server and your router would need to tell clients to use that server for lookups.



Is this relevant?

http://stackoverflow.com/questions/10495543/ping-hostnames-using-avahi-ubuntu-in -vmware-no-resolving

Mar 14, 2014 9:35 PM in response to eranj

eranj wrote:


The VMware fusion VMs are configuerd to bridged network mode.

This means that the VMs (and of course the real machines) each have there own IP address yes? What is your addressing scheme? Address range, subnet mask, default gateway and primary DNS? is your default gateway a local interface of a router that gets you to the internet?


eranj wrote:


Also, there are non VMs windows machines in the LAN.

Is it possible to avoid bonjour for using hostnames instead of IPs??


I don't understand why the computers are shown in finder, but I can't ping them using hostnames.

It only works with IP address.

The windows pcs and VMs show up in Finder most likely because you have connected to them as servers (to their shares). To do so, you are probably using SMB as the sharing protocol to connect with. SMB uses NetBIOS name resolution to resolve names to IP addresses. On a local LAN, it will perform this resolution via broadcast. On the other hand, "ping" uses hostname resolution on your mac. This is probably why they show in Finder but Ping does not resolve their names. Conversely, the default config for windows machines means that if hostname resolution fails, it will fall back to NetBIOS name resolution, so all the windows machines should ping each other fine, if they're on the same subnet.


The other possibility is that some or all of the machines have firewall rules that prevent ping responses. For example, a windows machine that has its network connection configured to "public" instead of "private" may very well refuse to respond to pings; although, as you say pinging the IP address works so this is not an issue.

Mar 14, 2014 10:02 PM in response to eranj

Although not as nice as a local DNS server, you can still use the old, yet reliable, "hosts" file to manually resolve hostnames to IPs. The hosts file is still a very reliable method for home networks with only a few statically addressed hosts to keep track of.


On a Mac or Linux, edit:


/etc/hosts


On Windows, edit:


C:\windows\system32\drivers\etc\hosts


Note that you will need to edit the file using administrative privileges or you will not be allowed to save your changes.


Also, as other have mentioned you need to make sure that your VM can ping the host by IP. If not, then you have some other issue to take care of first (NATing, IP subnet routing, firewall, etc.).

May 6, 2014 9:52 AM in response to eranj

You need to decide which machine will run DNS, it should probably be responsible for DHCP too so that it controls the IP's of the clients.


You configure the DNS server & tell the router/DHCP server to hand out that DNS server to clients via it's DCHP leases. That way clients always get the DNS from the local server. The server will always need to be available and it will need to forward unknown queries (so the internet still works for the clients).


MrHoffman has some nice tips for OS X DNS setup. Also see the OS X server section on this forum if you decide to use OS X for DNS.


Otherwise most linux distros will run dnsmasq or many other DNS/DHCP servers.


I suspect a router with Tomato or OpenWrt should be able to run a lightweight DNS server.

May 10, 2014 6:09 PM in response to eranj

eranj wrote:


All the machines get DHCP settings from a TP Link TL-WR941ND Router.

It serves as a DHCP and DNS server for the network.

All non-mac machines can ping each other using FQDN/ hostnames, and my mac also.

Only my mac can't ping them.

Even if I add .local to the search domain in the network preferences.

Macs don't like .local to be in the search domain, since it is generally used .local for Bonjour (mDNS) lookups.


If your domain is something.local you should really consider changing that. Use a domain that you actually own (so lookups that reach the internet don't break your LAN).

There is a bit of info at (& see the Apple KB linked from it).

http://labs.hoffmanlabs.com/node/1603


Mr Hoffman also has info for OS X & DNS server setup http://labs.hoffmanlabs.com/node/1436 it applies even if the DNS server isn't on the Mac.


To troubleshoot this you would need to figure out if the Mac is looking up via Bonjour or DNS. I guess you could either tcpdump on the Mac to see if it is requesting DNS from the router.

You'd also need to run dig to see if the DNS server is sending what you expect.


I have heard so many horror stories with Mac's on .local domains that I think changing that would be my first step.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Hostname resolving problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.