Solved

How to change 'localhost' ip address on workstation

Posted on 2012-12-25
7
667 Views
Last Modified: 2013-01-13
Hello Experts

This is a very easy one.

Can someone please show me how to change the ip address of the 'localhost' on my pc.

I believe there is somekind of 'host' or 'winhost' file that I need to change.

At the moment if I ping localhost it comes up with 127.0.0.1, which we all know is the loopback address. I want to change it to specific ip address.

Cheers

Carlton
0
Comment
Question by:cpatte7372
7 Comments
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 38720489
edit your hosts file and change localhost to point to where you want. (you need admin permissions)
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 38720514
I recommend against changing localhost to any other IP address.  You don't know how many other applications depend on that.  Instead, find the IP address of your machine and use that.  Here are two methods of finding your IP address: http://www.ehow.com/how_5621076_ip-address-windows-7.html
0
 
LVL 44

Accepted Solution

by:
Darr247 earned 500 total points
ID: 38720555
You need to take ownership of the %windir%\system32\drivers\etc\HOSTS file, first.

Then make a shortcut on your desktop with a target of
%windir%\notepad.exe "%windir%\system32\drivers\etc\hosts"
Start in: %windir%
and named HOSTS.

Then you can just open that shortcut when you want to make changes to HOSTS.

However, I don't really think you can change 'localhost' from 127.0.0.1 with HOSTS, as it's hard-coded...  in fact ALL 127.x.x.x addresses are reserved for loopback, so if you ping 127.100.100.100 you will get a reply whether it's in HOSTS or not; if you change the loopback entry in HOSTS to
127.100.100.100  localhost
flushdns/registerdns and/or reboot, then do
ping -a 127.100.100.100
it will still not resolve to "localhost"
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 38720575
Doesn't it work the other way around, ping -a will resolve names to IPs but not the other way around?  On this machine, 'localhost' resolves to '::1' which is the IPV6 version.
0
 
LVL 44

Expert Comment

by:Darr247
ID: 38720596
No... DNS resolves names to IPs.

Names are not needed at all to run a ping... when you ping a domain name it gets the IP from DNS and every hop along the path actually uses the IP address, not the name.

If you ping a reachable IP address no domain name is displayed; ping -a essentially does a reverse DNS lookup.
0
 
LVL 23

Expert Comment

by:DanCh99
ID: 38722512
what are you actually trying to achieve here, please?
Localhost is *supposed* to be the loopback address:

http://en.wikipedia.org/wiki/Localhost

If you can describe the actual problem, we can widen the scope of the answers.
0
 

Author Closing Comment

by:cpatte7372
ID: 38772581
Cheers
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I hope this helps those who have been battling the SanDisk / U3 problem for a while. For anyone that is running Windows 7 64bit and is receiving and searching the internet for the “Windows Error: Windows has allocated a drive letter to the U3 dri…
OfficeMate Freezes on login or does not load after login credentials are input.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now