hostname returns another device's name 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:
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