Cannot resolve Windows host names from Terminal

rubicon

Registered
I regularly connect my Mac to my Windows computer using Finder. However, I can't connect to the Windows computers using Terminal, Chicken of the VNC, or Remote Desktop Client - the hostname won't resolve. It works fine if I use the IP address. Problem is, I use DHCP at home and don't want to use static IP.

Doesn't anyone know how to get name resolution working? Why does it work in Finder but nowhere else?

I'm running OS X 10.3.6 using a Linksys WRT54G and trying to ping, VNC, or RDP to an XP host.

TIA.
 
You will need a way to resolve names to IP's. I use a FreeBSD machine with named running, then dhcpd that has the mac addresses of the specific machines, and gives them specific IP's. My DNS server resolves the names.

You can use /etc/hosts as well.
 
Righto, but what I don't understand is how Finder is resolving the names but other TCP/IP applications are not (such as RDC, VNC). It seems I need the Mac to lookup the DHCP client addresses from the local DHCP server.

Interestingly, my SuSE install can resolve DHCP client addresses just fine. It's only OS X having a problem.
 
The Finder is probably configured to use wins resolution or something similar in the Finder. What happens if you try "nmblookup windows-box-name" in terminal?

The trick is to figure out how to configure hostname resolving order, and to see if you can set wins lookup as a step...
 
nmblookup worked and gave me the IP address.

Any thoughts about the hostname resolving order and getting WINS in there?
 
An idea, why not add to ~/.bashrc (or whatever login script you need) something like:
export WINDOWS-BOX-1=`nmblookup hostname`

Then you can just log in using something like ssh user@$WINDOWS-BOX-1
 
This is all great, but I dont understand why it does not work.

This is a workaround, and I dont like those.
I need THE fix for this.

I know in linux you can use /etc/nsswitch and put in the different methods of host resolution like this:
hosts: files winbind dns

I tried it but did not work.
 
You could add the entry in your /etc/hosts file for that one Windows computer, or you could run a DNS server internally to resolve only the internal addresses. I have the same issues with my GNU/Linux systems when trying to access a Windows computer using the hostname. At work, I've modified the /etc/resolv.conf file on my GNU/Linux computers so that they could resolve the names to the IP addresses of the Windows computers. I've also modified the /etc/nsswitch.conf file to also search hostnames through DNS.

In Mac OS X, I've usually just added the DNS nameservers manually from the Network pane in System Preferences for the Macs at work if they don't get it from the DHCP server.

EDIT: Just noticed that you tried exactly what I mentioned in GNU/Linux, so you are obviously familiar with this. If you're using Tiger or earlier, remember that most everything is managed by NetInfo, so you might have to launch NetInfo Manager to make the changes. Be careful, though.....you can make some dire mistakes in there if you don't know what you're doing.
 
Sorry, but using a dns for resolving local ip addresses is again a workaround.
Same for /etc/hosts. If the IP changes (which is certainly possible because of DHCP host configuration) this will not work anymore.

I tried to solve this with nmbd (which is the deamon for netbios name resolution but without any succes.)
NMBD is installed by default on Mac OS X 10.5
 
Sorry, but using a dns for resolving local ip addresses is again a workaround.
Same for /etc/hosts. If the IP changes (which is certainly possible because of DHCP host configuration) this will not work anymore.

I tried to solve this with nmbd (which is the deamon for netbios name resolution but without any succes.)
NMBD is installed by default on Mac OS X 10.5

I don't understand why you would think this is a "workaround". Why else would you need a nameserver then? Imagine how painful the web would be without DNS nameservers. Remember that Windows uses other services in order to find other Windows computers on the network (WINS, NetBIOS, etc.). AppleShare was also able to resolve the names without need for a DNS service IIRC. To my knowledge, the only way to do name resolution with the TCP/IP protocol is through the DNS service in order to resolve it to the hostname. If I'm mistaken, can someone please correct me on this?

For the record, my wife's Windows laptop has the same problem when accessing my Mac and GNU/Linux PCs, so it's not just a non-Windows thing.
 
I don't understand why you would think this is a "workaround". Why else would you need a nameserver then? Imagine how painful the web would be without DNS nameservers. Remember that Windows uses other services in order to find other Windows computers on the network (WINS, NetBIOS, etc.). AppleShare was also able to resolve the names without need for a DNS service IIRC. To my knowledge, the only way to do name resolution with the TCP/IP protocol is through the DNS service in order to resolve it to the hostname. If I'm mistaken, can someone please correct me on this?

For the record, my wife's Windows laptop has the same problem when accessing my Mac and GNU/Linux PCs, so it's not just a non-Windows thing.

DNS is indeed very important for the internet. But NETBIOS is zero-configuration which makes it easy if someone joins the network temporarily.

Pls do mind that I can resolve hostnames with nmblookup, but ping does not use NETBIOS as name resolution, nor the browser does.

The nmbd daemon does netbios name resolving.

From a windows computer in the same network I can perfectly ping a FreeBSD or mac machine, but the Mac and FreeBSD dont use netbios for the ping command.
 
Last edited:
Thanks for your effort.

But sharing files is working..

I just want to be able to use netbios name for example Remote Desktop or CUPS(uses it for sharing printers automatically but as I cant resolve it, it is not working)
 
Sorry if this is reopening an old wound but looking through this thread sorted this out for me.

The problem is case sensitivity - at least it was for me!

If I ping the hostname exactly as it shows in Finder then I'm good. I wonder if there is a way to make OSX forget case with these NetBIOS names... I'm guessing it is the Unix responsible here.

Anyway, if one year on you are still suffering I hope this fixes yours too.

Thank!
 
Thanks for telling what did work for you. probably this will help others.

Unfortunately, I don't longer own a macbook.

I think I remember what my problem was, and it could be that this had to do with the system not trying to resolve with nmbd.

If I ever come across this problem again, I will try this out.
 
Back
Top