Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

2 Answers 2

up vote 5 down vote accepted

Edit file /etc/hosts and add line:

Of course instead of 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.