Skip to main content
Solved

Hostname, Computer name, and Local Hostname


Forum|alt.badge.img+6

When I image it seems as though only the computer name is getting set when I name a machine using the prompt in Casper Imaging.

I'm not sure if this is the expected behavior - but -my- expected behavior (maybe a bit misguided) is that it would not only set the Computer Name, but the hostname and the local hostname to match.

Am I way off here?

Best answer by Cem

something like this perhaps...

# set the computer name
setName=networksetup -getcomputername
scutil --set ComputerName ${setName}
scutil --set LocalHostName ${setName}
scutil --set HostName ${setName}

View original
Did this topic help you find an answer to your question?

12 replies

Forum|alt.badge.img+21
  • Contributor
  • 1028 replies
  • August 16, 2012

Can you please state what version of the OS you're trying to image and what version of the JSS you're on?


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 43 replies
  • August 16, 2012

Absolutely - sorry for the omission.

  • 8.6
  • 10.7.4
  • Image based on Composer snapshot of 10.7.4

Forum|alt.badge.img+17
  • Contributor
  • 881 replies
  • August 16, 2012

I ran into so many issues with this in the past due to Apple's auto-naming that I explicitly set all three to be the same, using scutil.


Forum|alt.badge.img+19
  • Contributor
  • 437 replies
  • August 17, 2012

yeah, I do the same as alex. scutil in a script for the win on this one.


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 43 replies
  • August 17, 2012

Sounds like a plan - since I've already got the computer name set correctly - do you guys just get the computer name and then set it as a variable (computername) in the script and run scutil --set HostName $computername ?


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • August 17, 2012

The 3 possible names that a Mac can have is one of the things I often get ribbed about by my fellow Windows colleague. They find it ridiculous that there can be 3 possible names, potentially all different in certain circumstances. I can't say I really blame them. A new OOB Mac setup sets all these the same, but in an imaging or managed environment they can get out of sync unless you do the scutil naming commands as mentioned above.


Forum|alt.badge.img+17
  • Contributor
  • 352 replies
  • Answer
  • August 17, 2012

something like this perhaps...

# set the computer name
setName=networksetup -getcomputername
scutil --set ComputerName ${setName}
scutil --set LocalHostName ${setName}
scutil --set HostName ${setName}


Forum|alt.badge.img+6
  • Author
  • Contributor
  • 43 replies
  • August 17, 2012
#!/bin/sh

hostname=`jamf getComputerName | cut -c 16-34`
localhostname=`jamf getComputerName | cut -c 16-26`

echo "FQDN hostname will be set to $hostname"
echo "Local hostname will be set to $localhostname"

/usr/sbin/scutil --set HostName $hostname
/usr/sbin/scutil --set LocalHostName $localhostname

exit=0

bentoms
Forum|alt.badge.img+35
  • Legendary Contributor
  • 4331 replies
  • August 17, 2012

So does

sudo jamf -setComputerName <some name or action>

Not work?


Forum|alt.badge.img+21
  • Contributor
  • 1028 replies
  • August 17, 2012

Not if the JSS's record has already been hosed up.


jhbush
Forum|alt.badge.img+26
  • Esteemed Contributor
  • 539 replies
  • August 17, 2012

I use this ```
scutil --set HostName $(scutil --get LocalHostName)
``` as part of my first boot script. I also write the name out to a file in case I need to change it back if a user renames it something non-standard.


donmontalvo
Forum|alt.badge.img+36
  • Legendary Contributor
  • 4293 replies
  • August 17, 2012

The $HostName attribute has always been a PITA for us, as it uses whatever DNS thinks it should be.

Not saying Microsoft is playing a cruel joke on the Mac community, but I really wish DNS could play nice with Macs...a good start would be to enableScavenge Stale Records by default in DNS...

http://technet.microsoft.com/en-us/library/cc959277.aspx

</rant>


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings