Re: Obtaining local host name
Re: Obtaining local host name
- Subject: Re: Obtaining local host name
- From: Allan Nathanson <email@hidden>
- Date: Tue, 24 Nov 2009 09:46:32 -0500
There's actually 3 "names" in play.
1. the "ComputerName" is the user-friendly name (like "Allan's Mac Pro") that's set in the Sharing pref pane.
2. the "LocalHostName" is the .local name used by Bonjour. When you change the "ComputerName" in the Sharing pref pane the code tries to transform that name into one that fits within the constraints of a DNS label. But, if you don't like the transformed name you can also use the pref pane to set the name independently (e.g. I might use just "macpro").
3. the "HostName" is the BSD name associated with hostname(1). This is the name that typically shows up in a shell prompt. By default, the name is not fixed. Depending upon what's available, the name will be derived from a reverse DNS query of the hosts primary IP, can be derived from the DHCP reply, or will follow the "LocalHostName". You can force this name using "scutil --set HostName <your-BSD-name>".
- Allan
On Nov 24, 2009, at 6:13 AM, Kenny Millar wrote:
> For what it's worth, here is a strange but related issue that you might like
> to be aware of.
> My Mac is imaginatively named 'devMac' and lives on the corporate network at
> work. It gets it's IP address and gateway settings etc etc from the
> corporate DHCP server.
>
> In system preferences, under 'sharing' the computer name is set to "devMac"
> and the text says "Computers on your local network can access your computer
> at: macDev.local"
>
> However, and this is the strange bit. If I open a terminal session, the
> prompt, which should contain the computer name, reads "BobsDellLaptop:~
> kenny$" (this name is subject to change from time to time!)
>
> This means that the terminal session (or whatever) has done a reverse lookup
> of it's own IP address and got the wrong name back from our corporate DNS
> system. I guess this is a fault with the DNS server or something similar,
> but still, it shows that somewhere under the hood of Mac OS X it does not
> use the user-supplied information, but rather tries to figure it out for
> itself.
>
> -Kenny.
>
> -----Original Message-----
> From: macnetworkprog-bounces+kennymillar=email@hidden
> [mailto:macnetworkprog-bounces+kennymillar=email@hidden] On
> Behalf Of Peter Sichel
> Sent: 24 November 2009 10:03
> To: MacNetworkProg Mac Network
> Subject: Re: Obtaining local host name
>
> On Nov 23, 2009, at 4:41 AM, Quinn wrote:
>
>> At 14:31 -0500 22/11/09, Peter Sichel wrote:
>>> What confused me is that the LocalHostName may not exist (be null) until
> you advertise a service, but the default name for your service will use the
> computer name. The statement in Sharing Preferences that other hosts on
> your LAN can access this computer using the LocalHostName is not true in the
> default case of publishing your own service.
>>
>> I don't understand this comment. What test are you running and what is
> going wrong?
>
> My program Phone Amego has a Caller ID sharing feature that allows a copy of
> the program running on one host to subscribe to another. When you turn on
> "Caller ID Sharing" the program advertises a service. When you browse for
> services from another Phone Amego, the service appears with the
> corresponding "Computer Name."
>
> When the user selects a service and presses "Subscribe", the local instance
> sends a subscribe request to the remote service that includes the
> LocalHostName. The remote service then adds this LocalHostName to its
> publish list. Notice it does not browse for the service name, but receives
> it in a subscribe request from the client.
>
> This is a bug if the LocalHostName is not the same as the Computer Name.
> The publish will fail to resolve the corresponding NSNetService. The
> Sharing Preferences panel says other hosts on your LAN can access this
> computer using the LocalHostName, but that's not true in the default case of
> advertising your own service, you must use the local Computer Name or it
> won't work.
>
> - Peter
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden