Previous 1 2 Next 15 Replies Latest reply: Aug 17, 2008 6:54 PM by baltwo
electronic_cat Level 1 (0 points)
I need help accessing a computer on my local network by
hostname. I can ping it by IP, but I can't ping it by hostname. The
computer shows on the Finder under "shared" with a name.
But I can't ping by this name. Any ideas of how to get ping working by hostname? Also, this IP is assigned via DHCP, so a static configuration is not an option.

I have tried adding ".local" to the hostname. Also, I have gone into Parallels and successfully pinged by hostname.

The computer is an electronic piano-- I cannot do any configuration. Also, I am writing documentation for a sourceforge Java program to access the piano. It will be easiest to tell people to check their finder, and enter that name or something derived from it into the program. That works for Windows, but I don't know what to tell them for the Mac. I also don't know an easy way to tell them to find the IP address.

iMac, Mac OS X (10.5.4)
  • baltwo Level 9 (62,215 points)
    Can't help with the first part, but these two AS scripts get the internal and external IP address:

    get int IP add:

    *set ip_internal to do shell script "ipconfig getifaddr en0"*
    *display dialog "My internal IP address is: " & ip_internal*

    get ext IP add:

    *set myIP to word 25 of (do shell script "curl")*
    *display dialog "My external IP address is: " & myIP*
  • electronic_cat Level 1 (0 points)
    Thanks for helping. Would ifconfig get the IP address of the piano's computer? That is what I need. I read that bonjour was supplying the Shared list to Finder, so Bonjour must know the IP. I don't want the users to have to download an additonal program. (I know you were not suggesting that, but I found something called Bonjour Browser that might or might not work, but is not a good option.)

    I do know a roundabout way for them to get the IP with some software that comes with the piano, but I can't figure out why the name does not work when it does in Windows and even in Parallels on the same machine. I want to keep it as simple as possible.
  • baltwo Level 9 (62,215 points)
    I don't know, since I don't piano nor do wireless or windoze.
  • glsmith Level 3 (875 points)
    "ifconfig" is a Unix command (the Mac being a Unix-base system), so most Unix systems will have the command available. The equivalent (or similar, at least) command in Windows is "ipconfig /all". This piano computer is likely based off of Unix or Windows, so just try both of those commands. Now, this piano computer may not make that command available to you, may have gone in an named the command something else, etc -- like baltwo, I have no idea what kind of system it actually is so can't say for sure if either command will work. You'll just have to experiment.

    As for your name issue. Your Mac needs to be able to resolve that IP address to a name -- you don't get that for free just because Bonjour shows you a name in the Finder. Typically name resolution is handled by DNS, or by local files on your Mac (/etc/hosts, for example). A DNS server is something typically provided to you via your ISP, or your company network, etc, and its IP is given to you via DHCP. My guess is that your Windows setup within Parallels has access to a DNS server and so can resolve the piano's name. Or, the piano is really a Windows box under the hood and so is able to communicate its hostname to your Parallels Windows box via something like WINS (another type of name resolution protocol that only Windows uses).
  • electronic_cat Level 1 (0 points)
    I do not have any access to the piano, which is Linux. It is on a local network only. I guess I'll just use the kloogy method to find the IP that I have. I hate to admit defeat that Windows can do something that the Mac can't. The Mac finds it and can view the files on it, so I think it must know the IP.
  • glsmith Level 3 (875 points)
    The Mac can do it; simply set it up in /etc/hosts. Windows isn't magic, so you could also take a look at its settings to see where it is getting its name resolution from...
  • electronic_cat Level 1 (0 points)
    I'm not getting it. The users I am writing documentation for want to use the hostname (as seen under "shared" in finder) as an address of a "black box" piano/computer on their network to access the piano from a Java program running on the Mac. They do not know the IP address. I think you are telling me to put the IP address in /etc/hosts. But I don't know the IP address. That is my point. Also, this IP is assigned via DHCP. On Windows, the Java program will accept the hostname which shows up in the list of network connections. That same hostname does not work on the Mac. I thought there would be some utility I could run that would input a hostname and give me an IP address. On Windows I can ping the hostname and get the IP. I can't do that on the Mac, it can't reach the piano via hostname. My Windows system under Parallels is as vanilla as they come. Nothing was set up special. In this case Windows "just works".
  • baltwo Level 9 (62,215 points)
    Launch Network Utility->Ping->enter computer name (on my machine it's localhost), and click on Ping. I get PING localhost (, implying to me that my IP is
  • glsmith Level 3 (875 points)
    I can ping it by IP, but I can't ping it by hostname.

    This is what I was basing my information off of. Sounded like you did know the IP address. I guess you were talking about a different computer?

    If you can ping the hostname of the piano from Windows, then you know the IP address. Take that IP address and add it to /etc/hosts on the Mac and give it whatever name you want.

    If you're asking how would you find this information out in general, without having another machine that knows the IP/hostname map, and without having access to information on the "piano", then I don't know. As I said earlier, Windows is bound by many of the same rules as the Mac, so it has to be getting IP/name information from somewhere. It's either lmhosts (its /etc/hosts equivalent), WINS, DNS, etc. Again, take a look at some of the settings on your Windows box. Perhaps the DHCP server is giving out a DNS server but the Mac is ignoring it or is somehow not using it correctly. Perhaps it's using WINS (if so, then you can configure your Mac to use this protocol).
  • electronic_cat Level 1 (0 points)
    My apologies, my lack of knowledge is making it hard for me to express myself. I am trying to write documentation for a Java program that runs on the Mac and the PC. The program is used by computer/network novices, like me. On the PC, they can input the name they see in My Network Places. On the Mac, what seems to be the equivalent, Shared, and in fact shows the same name as the PC, does not work. It isn't the Java program because Ping by name works on the PC and not the Mac. I was hoping there would be some option on the Mac I could set and suddenly everything would start working.

    I have a program furnished by the Piano Manufacturer, which as a side benefit gives the IP, but since the IP may change from day to day, it will mean that they may have to venture to this not-so-friendly program from time to time. I was hoping to find a way to access the piano by name.

    I realize my original question did not focus well on my needs, but I hope now my problem is more clearly expressed. Your answer gave me lots of good information, but did not solve the immediate problem.
  • baltwo Level 9 (62,215 points)
    If you're writing the documentation, then you have access to the coders. Ask them.
  • glsmith Level 3 (875 points)
    Yes, it's clearer now, thanks

    There is no easy thing for you to do, I'm afraid. I'm not exactly sure how the Windows box is mapping the IP and name (possibly WINS, maybe something within CIFS that I'm not familiar with). It's likely that you could eventually get your Mac to do the same thing as the Windows box, but it will be complicated. Windows was designed to exist in a Windows network (which is what you've got with the piano, even though it may be based off Linux), and it's taking advantage of that. This is a case where the Windows experience is certainly more "friendly" than the Mac...
  • electronic_cat Level 1 (0 points)
    Well, you've all helped. Now I know it is not a simple question, so I'll just have to live with it, and tell them the kludgy way to get the IP. I want the documentation to be professional, so it helps to know that I have not missed something. Thanks to all for your suggestions.
  • electronic_cat Level 1 (0 points)
    In terminal,
    smbutil lookup hostname
    gives the IP.. a good step in the right direction.
Previous 1 2 Next