# hostname strange behavior



## waiting_for_OSX (Feb 12, 2008)

I'm using Leopard 10.5.2, MBP. 

When I was using 10.4.something, I set the hostname to X using system preferences -> sharing. Everything worked fine.

Months later, after upgrading to 10.5.1, I set the hostname to Y by the same method. This appeared to work properly. I then upgraded later to 10.5.2. 

When I started the terminal I discovered my bash shell prompt, which is defined as:

$echo $PS1
\h:\W \u\$

still said 

X:~ myname$

I discovered my /etc/hostname file still thought my hostname was X.
I su root, set the hostname to Y with the hostname command, restart the terminal app and then my bash shell prompt said:

Y:~ myname$

All was good. Closing the terminal, I then went back to system preferences -> sharing, and set the hostname to Z. I restarted the terminal, and my prompt was back to

X:~ myname$

Which was very surprising. Not only was it not what I expected, it wasn't the error I would have expected.

Does anyone know how hostname is getting changed, or how to fix this problem?


----------



## michaelsanford (Feb 21, 2008)

I noticed the same behaviour, which seemed to be caused by my DHCP controller (i.e., my router).

I have an iBook with two interfaces (iBookEN and iBookAP for ethernet and airport respectively). I use two pipes for a complex QoS implementation.

I noticed that, even though my hostname in System Preferences was iBook, it would take on the hostname given by my DHCP controller (or, more specifically, the one provided as a DHCP Client ID, given above).

But, after having used two routers (a Linksys WRT54G-CA v6 with dd-wrt custom firmware and a DLink DI-624 with [FONT=Arial, Helvetica, sans-serif]2.76[/FONT]) I have only experienced hostname changes with the Linksys, not with the DLink.


----------

