Set the hostname/computer name for macOS
I've had an issue with a Macbook Pro on one particular network where, even though I've set the computer name via system preferences, in the terminal (and via hostname) it's showing as the network-generated name.
This seems to help tidy things up.