2

I realized that the hostname had changed while I was doing some work using terminal in OS X Yosemite. I thought there might be an IP address conflict so I reset it. However I still get another device's name (someone else's iPhone, to be exact) when I use the hostname command:

Last login: Fri May  1 15:52:42 on ttys000
SomeonesiPhone:~ irem$

SomeonesiPhone:~ irem$ hostname
SomeonesiPhone.wireless.duke.local

What's going on and how can I fix this?

It appears the IP address has not changed. But the address that I get by doing ipconfig getifaddr en0 is different from my public IP address. I looked up my public IP address using Google, like this:

enter image description here

0

1 Answer 1

2

By default, your Mac will take the host name from the router when it received a DHCP reservation reply.

You can change this by not using DHCP or fixing the router or as a last resort over-writing the host name once you notice it's gone amok:

sudo scutil --set ComputerName whatever
sudo scutil --set LocalHostName whatever
5
  • It did not change anything. The hostname does not get changed. The computer name has been Irems-MacBook-Pro all the time, and it still is. Commented May 1, 2015 at 21:47
  • @sodiumnitrate When you spawned that shell - the host name was SomeonesiPhone and the hostname command agrees. Perhaps you are referring to the other two possible names - HostName, ComputerName, LocalHostName - not changing? Either way, set it the way you want and then have your shell fix $PS1 (or quit the shell and start a new one once you've resolved the naming confusion)
    – bmike
    Commented May 1, 2015 at 21:54
  • Ok, I got a little confused. So when I do scutil --get ComputerName or the other 2, I can see that it's been changed to whatever I want them to be. I guess hostname is something different, which is still someone's iPhone. The question is what can I do to get my hostname changed back to what it was. I understand that it's a screw-up with the network (although not sure about how), but I can't do anything there as it's the school's network. I've contacted support, but they didn't seem to have much idea. Commented May 1, 2015 at 22:02
  • @sodiumnitrate After using --get to verify all three, set the ones that are wrong and then if needed, restart terminal.
    – bmike
    Commented May 1, 2015 at 22:14
  • Using a fixed IP address and restarting terminal solved this for me. I would still like to know where the strange hostname came from. It was nothing I would ever use but it was not incorrect, either. Commented Mar 5, 2021 at 18:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .