Super User is a question and answer site for computer enthusiasts and power users. 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 changed the /etc/hosts and added an ip address to point localhost to a different computer like:

192.x.x.1 localhost

But it is not working and when I ping to localhost it pings ::1 which is the default route

Adding an alternative name however works, its just the localhost that cannot be overwritten.

How to solve this problem?

share|improve this question
Localhost is probably built-in, though I couldn't promise that. If you use a different (unreserved or at least non-well-known) name, does THAT work? – Mark Allen Feb 6 '13 at 1:12
@MarkAllen Yes they do – Starx Feb 6 '13 at 1:14

You cannot change the localhost's IP address.

Note the comment preceding the lines in hosts file:

# localhost name resolution is handled within DNS itself.
# localhost
# ::1 localhost

So, you don't even need to enter localhost in your hosts file in order get it work, it's built into the TCP stack since it's a loopback address.

In TCP/IP a loopback device is a virtual network interface implemented in software only and not connected to any hardware, but which is fully integrated into the computer system's internal network infrastructure. Any traffic that a computer program sends to the loopback interface is immediately received on the same interface.

Here are some useful comments from another answer on SuperUser:

Your localhost is used to refer to your computer from its "internal" IP, not from any "external" IPs of your computer. So, the ping packets don't pass through any physical network interface; only through a virtual loop back interface which directly sends the packets from port to port without any physical hops.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .