Alternate Title: "Notes On Becoming More Familiar With How JSS Determines A Computer's Name"
RESULT SUMMARY: The output of `scutil --get ComputerName` needs to be set correctly before running `jamf recon` in order for the Computer Name in JSS not to be set incorrectly.
PROBLEM: Some of the names for computers in JSS do not match our organization's naming convention. Sometimes this happens to a machine that has been in the wild. Most of the time this happens immediately after imaging.
OBSERVATIONS: The incorrect name, when not caused by human error or abused admin rights, is invariably related to DNS. It is sometimes localhost and it is sometimes a name that can be found on our DNS.
Here are the results of some experimentation with a MacBook Air running OS X 10.8.3. By my convention, all CamelCase words indicate the value was derived from the scutil tool.
The initial settings were as follows:
Computer Name in JSS (v8.71): mylaptop
ComputerName: mylaptop
LocalHostName: mylaptop
HostName: mylaptop
FQDN for laptop's IP: foo-test.example.com.
IP of FQDN: 10.101.3.108
On the laptop I verified that my machine had the same HostName, LocalHostName, and ComptuerName as outputted by scutil. It also had the same entry in JSS verified through the web interface.
On the DNS server I created foo-test.example.com A and PTR records for the IP address being handed out to my test laptop's Ethernet port. Airport was turned off.
In other words, DNS returned a different name than the names set on the laptop.
After rebooting, this is what I found:
$ networksetup -getinfo "USB Ethernet" | grep "^IP address"
IP address: 10.101.3.108
$ host 10.101.3.108
foo-test.example.com.
$ host foo-test.example.com
10.101.3.108
$ hostname
mylaptop
$ scutil --get ComputerName
mylaptop
$ scutil --get HostName
mylaptop
$ scutil --get LocalHostName
mylaptop
When I ran `sudo jamf recon, the JSS record did not change. When I changed HostName to "", then results of the
hostname` command become the FQDN name, which didn't match the ComputerName.
$ sudo scutil --set HostName ""
$ scutil --get HostName
HostName: not set
$ hostname
foo-test.example.com
NOTE: The results of `hostname` do not always match HostName. There are FOUR DIFFERENT names a Mac OS X computer can have. (Anyone know why?)
When I ran recon with the HostName set to "", JSS kept the same Computer Name.
So far everything behaved as expected. So how does the name in JSS get changed to an undesired name?
I then set the ComputerName and LocalHostName to "", and set HostName to "mylaptop-hostname". Upon reboot ComputerName and LocalHostName were still "" and HostName was "mylaptop-hostname". When I ran `jamf recon` the JSS Computer Name changed to "mylaptop-hostname". Now we are getting somewhere.
When I set all three names to "", the FQDN became the output of `hostname. When I ran recon, Computer Name was set to
hostname`.
I also discovered why some computers were getting named "localhost". If the IP address did not return a FQDN when checked in DNS, then `hostname` was set to "localhost" which consequently made its way to the JSS.
CONCLUSION: Recon uses ComputerName if available, then HostName, and finally `hostname` to update the Computer Name field in JSS. At some point in the imaging process, the computer is checking into JSS without having a ComputerName or HostName set. This results in FQDN being used if the network is available or localhost if it is not.
PROPOSED SOLUTION: Set the ComputerName, HostName and LocalHostName to the same thing and set them before the network is activated.
What is the best way to accomplish that? Under old UNIX it would /etc/hostconfig or in /etc/hosts, but those are depreciated files in OS X. Daniel handles it by deleting stuff in SystemConfiguration/preferences.plist and com.apple.smb.server.plist then letting the post imaging scripts set the name.
RELATED THEADS:
- "Hostname, Computer name, and Local Hostname - https://jamfnation.jamfsoftware.com/discussion.html?id=5127
- "Casper not setting computer name when imaging Mountain Lion" - http://jamfnation.jamfsoftware.com/discussion.html?id=5592
- Casper Imaging 8.6 Not Naming Computerhttps://jamfnation.jamfsoftware.com/discussion.html?id=5078