Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm testing an application on my PC, this application connects to various servers so I need to mimic that on my box.

How can I map hostnames to 127.0.0.1?

localhost already refers to 127.0.0.1, but how could I add more such as server-1 and server-2 to 127.0.0.1?

I'm on Windows 7.

Thanks

share|improve this question
    
Use different port numbers like localhost:1111 , localhost:2222 –  Shakehar Feb 24 '11 at 10:10
    
I want to use different hostnames not different ports –  user155695 Feb 24 '11 at 10:11
add comment

1 Answer 1

up vote 8 down vote accepted

Just edit your hosts file and use that to point to 127.0.0.1 or the local IP address of your machine.

The file is normally in: /windows/system32/drivers/etc

eg - here's mine and I have been testing a few 'servers' as you can see:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost
    192.168.202.32  feng
    192.168.202.241 helpdesk
    192.168.202.241 wiki
    192.168.202.241 rs
    192.168.202.241 precurio    
    192.168.202.241 zendto
share|improve this answer
    
You can put multiple hostnames in a single address line. –  grawity Feb 24 '11 at 11:08
    
True - I put them on separate lines as its quick and easy to comment them in and out as needed. –  Linker3000 Feb 24 '11 at 22:43
add comment

Your Answer

 
discard

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.