Terminal has strange names

There is something weird happening in Lion (10.7.1 on 2011 MBP) My termnial will sometimes adopt random names when on wifi. My computer's name is Sora and I don't plan on changing it for now. When I first started noticing this, terminal has taken on the name of thor and zickelpop-pc (attached)


The name reverts back to Sora when disconnected from the network.


Screenshot below-



User uploaded file

MacBook Pro, Mac OS X (10.7)

Posted on Sep 27, 2011 8:31 AM

Reply
5 replies

Sep 27, 2011 3:14 PM in response to chattphotos

As MrHoffman as said, "bash" (your shell) obtains your hostname by doing a reverse DNS lookup using your IP address. It then displays whatever is returned from your DNS server.


Frequently your DNS server on a home network is your router.


"bash" is an open source package, and as far as I know is not modified by Apple, so bash has the same behavior on any Unix system.


"man bash" -> "PROMPTING" will give you all the magic characters that can be used in the PS1 prompt string, should you wish to customize your PS1 prompt string. \h is the what provides the hostname information.

Sep 28, 2011 8:30 AM in response to chattphotos

Having bash display a hostname on the command prompt changes nothing.


The DNS server is going to return that hostname for anyone that queries it with your IP address. It is just a name. How is that different from returning Sora for anyone that does a DNS lookup on your IP address?


If you always want to see Sora, then specify your own PS1 prompt in your shell initialization file.


If you want to dynamically get your System Preferences -> Sharing -> Computer name, you could use this bit of code:


COMPUTERNAME="$(systemsetup -getcomputername)"

COMPUTERNAME="${COMPUTERNAME/Computer Name: /}

PS1="${COMPUTERNAME}> "


Note: Whenever you are on an open network, such as a college campus, coffee shop, community WiFi, etc..., you should keep in mind that anyone could be probing your Mac's open ports. By default the Mac does not open external ports, but as you activate System Preferences -> Sharing features, you will be opening ports. Making sure you have strong passwords can help. Also you could consider enabling the Mac OS X Firewall (System Prefrences -> Security).

But just because some DNS server has a different name for your Mac than what you want, is not a security issue.

Oct 1, 2011 8:53 AM in response to BobHarris

One small correction to what BobHarris wrote: a home gateway router seldom provides a DNS server. That device will usually pass out the IP addresses of your ISP DNS servers, and your local network (when configured behind a NAT router) won't really have DNS services for your network, beyond Apple's Bonjour-based networking actve on your network. (You'll get a form of forwarding, but usually no local DNS services.)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal has strange names

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.