This is a result of DHCP. I've closed this as a duplicate, but please edit the post if you can't make use of the linked answers to solve your issue. Explain what about the linked answers doesn't make sense or apply :-) The one time fix is to open Sharing system preferences and rename the Mac to what you want it to be.
– bmikeMar 27 '15 at 13:32
running sudo scutil –-set HostName MacBookPro is not doing anything. It shows > prompt on other line
– Volatil3Mar 27 '15 at 18:39
sudo scutil –-set HostName MacBookProis not doing anything. It shows>prompt on other line – Volatil3 Mar 27 '15 at 18:39