Why is bash shell sometimes saying I'm at @localhost while other times it says I'm at @computer-5?

1 Answer 1


Some DHCP servers (and clients) are configured to assign a hostname just like an IP address. In these cases the computer's hostname does in fact change to e. g. computer-5 (until it gets a lease assigning a different name, or the lease is relinquished). localhost will still work for the loopback interface, but the DHCP-assigned hostname will (or should) resolve to the DHCP-assigned address specifically.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.