Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Centos 5.8 server. How can I add my server IP address so that it reflects when I run the command hostname -i

At the moment the command only shows the loopback IP and the software I am trying to install complains that the server IP is not reflected here.

share|improve this question
up vote 5 down vote accepted

Edit file /etc/hosts and add line: this.is.my.host

Of course instead of this.is.my.host enter proper hostname. You can check it by running hostname without any parameters.

share|improve this answer

The hostname of the machine can be changed in the following file




is for local IP > name resolution (No DNS available)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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