Automate Setting DHCP client ID to Hostname on Macs

kstembridge
New Contributor

We have 300+ Macs in our environment and have found that they are reporting in other tools like McAfee and Ivanti that they are Windows machines because they are pulling an IP address that a Windows machine previously had. Looking through the Landesk forums, the only thing besides editing the host file I haven't tried is setting the "DHCP client ID".

If your DHCP Server supports it you can go into System Preferences -> Network -> Select your adaptor on the left -> click the Advanced button -> Set the "DHCP client ID" to your hostname.

I have verified that the Macs have the computer name set correctly by using Jamf and another script to set the computer name. I also have "Use a dynamic global hostname" unchecked in the network preferences.

Does anyone know of a way to script the DHCP client ID to the current hostname of the Mac?

1 ACCEPTED SOLUTION

Jerneheim
New Contributor III

Hi Kyle,

The networksetup command will do this for you.

networksetup -setdhcp Wi-Fi $(hostname -s)

Good luck.

Cheers
Patrik

View solution in original post

1 REPLY 1

Jerneheim
New Contributor III

Hi Kyle,

The networksetup command will do this for you.

networksetup -setdhcp Wi-Fi $(hostname -s)

Good luck.

Cheers
Patrik

View solution in original post