So basically I want to map the IP address to localhost.

So that when I browse to:

It will fetch:

Does anyone know how I could go about doing this? Unfortunately the hosts file does not allow these kind of mappings.


What if you add as an extra IP address to your machine.

| improve this answer | |
  • Straightforward, but the disadvantage here would be that the machine would be visible to others as that address. This could cause conflicts, or the desired address might be on a completely different network which won't work on the network(s) to which the machine is currently attached. – kbluck Apr 16 '10 at 15:39
  • I would agree with you on the first point, assuming the ip address is within your own network range. And it would cause ip conflicts if you are attempting to use the address of an existing machine on your network. However, if the ip address is on a completely different network range, then should work fine and it effectively means that your machine and your machine alone is on a second network. – sgmoore Apr 16 '10 at 18:48
  • See superuser.com/a/768375/144375 for instructions to do so. – Amir Ali Akbari Oct 20 '14 at 7:28

The best way to do this is to install a loopback network adapter and assign it the desired IP address. The machine will consider itself as "owning" that address, but it won't be visible on the actual network. For that matter, the machine won't even need to be connected to a real network.


You may have routing issues for the subnet surrounding the address you're hijacking by this method. This can be overcome by adding a persistent route for the affected subnet with a cheaper metric so that only the specific IP you want is routed to the loopback adapter, while the rest of that subnet is routed out to the real network.


You can also crank down the subnet mask so that only a handful of addresses are affected, for example using subnet mask which will be a block of only 4 IP addresses. As long as your machine doesn't need to contact any outside hosts at any of those 4 IPs in the block, it will suffice without messing with persistent routes.

Oh, and of course you'll need your web server to be listening on that IP address. Setting it to listen on "all" addresses should suffice.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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