Solved

How to change 'localhost' ip address on workstation

Posted on 2012-12-25
7
669 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 79

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 83

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 83

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:Danny Child
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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently purchased an HP EliteBook 2540p notebook/laptop. It has two video ports on it – VGA and DisplayPort. HP offers an optional docking station for the 2540p that also has both a VGA port and a DisplayPort. There are numerous online reports do…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
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.

895 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

11 Experts available now in Live!

Get 1:1 Help Now