We help IT Professionals succeed at work.

hostname of my macs change when using DHCP

I'm experiencing a new crazy issue.  I have about 9 MAC computers on a network with mostly Windows PCs.  I have a windows 2012R2 DC, with AD, DNS, DHCP, etc...
If the Macs use a static IP, everything works fine, the hostname stays what is configured by the user.

As soon as I change the manual IP to DHCP on the MAC, after a reboot, the hostname of the PC randomly changes to a windows PC name.
It's completly random, as different MACs use different windows PC names.   Where do I even begin to troubleshoot this issue.

I am running different versions of the mac, on most of the macs, i'm running Mojave.  A few are running Catalina.
Comment
Watch Question

Dr. KlahnPrincipal Software Engineer
Commented:
On Windows this issue is handled by an option in the network connection setup:  "Register this connection's address in DNS."

Speculating:  I suspect that on a mac there is an equivalent option, but it is not enabled by default.  In that case DNS would reflect the name of the last system that was sitting on that IP.

"In our environment the act of binding a Mac to Active Directory automatically adds a record to DNS with Mac's host name plus our Active Directory domain. Active Directory domains and network domains that are assigned by DHCP aren't always the same."

https://www.jamf.com/jamf-nation/discussions/4067/dns-registration-parallel-to-windows-registration

So, could be an AD issue.

If giving each Mac a fixed IP solves the problem ... for 9 problem computers, not 250 ... I/M/O do that.
You must have turned on the dynamic hostname.  I always thought it was off by default.  I just checked and don't see it enabled.

Open System Preferences
Select Sharing.
Click on the Edit button just under the Computer name field.
Make sure the check box for Use dynamic global hostname is unchecked.

Instructions here also: https://knowledge.autodesk.com/search-result/caas/sfdcarticles/sfdcarticles/Setting-a-persistent-hostname-on-a-Mac-workstation-that-uses-DHCP.html
DanNetwork Engineer

Author

Commented:

Actually, the "use dynamic global hostname" is NOT checked and it's still having this behavior.

DanNetwork Engineer

Author

Commented:

under system preferences -> sharing, If i turn off remote management, the name in terminal is correct.

As soon as I turn on remote management, the name displayed is wrong.


So how does the mac get it's computer name from DNS, as I'm trying to figure this out.

Maybe the GUI is wrong.  Toggle it on, then toggle it off.


Check all 3 names in the Terminal.app command line.
#Used by computer / unix
   scutil --get HostName
#Used by Sharing
   scutil --get LocalHostName
#Used by Bonjour
   scutil --get ComputerName


Make sure all names are set and your hostname should remain fixed.
   scutil --set LocalHostName MyHostName
DanNetwork Engineer

Author

Commented:

after looking in DNS, I noticed the IP address of my mac is 192.168.102.115, which is a DHCP IP.

In the forward lookup zone, this IP has the correct name of admins-mac-mini

In the referse lookup zone, this IP points to a different name,udzyndra,  which is not correct. The name in the reverse

lookup zone is listed numerous times over and over.  The computer udzyndra is actually a windows PC, so not sure why most of my macs are using this windows name. 


Is it safe to just delete all entries in my reverse lookup zone?


I tried setting the DHCP client ID, but that didn't.


If I use static IPs on my macs, then this issue doesn't happen.  I think there's a total of 13 or 14, I was mistaken earlier about the total number of macs, so I really want to use DHCP on all of them.




DanNetwork Engineer

Author

Commented:

serialband, I can see this happening to one mac, but it's happening on EVERY mac.

Very strange, I will try what yo suggested.

DanNetwork Engineer

Author

Commented:

serialband,


So I ran those commands and now when I go to system preferences -> sharing, it doesn't list the computer name there anymore, but IP address.  I guess it kind of helped, since the wrong computer name is not there, but the problem is, it's now an IP address and I need it to use a computer name, as it's much harder to remember to remote desktop into computers by IPs rather than names.


Anything else I can try?

Have you tried setting all 3 names to make sure all 3 are set?

  scutil --set HostName My HostName
  scutil --set ComputerName HostName
DanNetwork Engineer

Author

Commented:

I figured out the exact problem, I just don't know how to solve it.



When a MAC is using DHCP, it does NOT update the DNS forward zone records

 

DHCP is working fine, when a MAC gets an IP lease, the correct computer name is listed in DHCP

 

It does try to use the DNS entry listed in the Reverse lookup zone

If a record with the IP address it has is already in there, it will use that DNS name in the remote sharing section and in terminal


If a record for the IP it's using is NOT in the reverse lookup zone, it will just use it's IP address in the remote sharing section and in terminal

 

DNS has been verified, in the reverse lookup zone, by default the setting is enabled "update associated pointer (PTR) record"

 

The MACs just don't update the PTR record, they only read it, so they will use it if it's in there, but will not update or add an entry


DanNetwork Engineer

Author

Commented:

Does anyone know any good vendors that work with MACS and Windows in the Sacramento, CA area, as I think it's time for me to call a company to come research the issue.

DanNetwork Engineer

Author

Commented:

thanks guys for your help