How can I map multiple hostnames to localhost?

31,876

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:
31,876

Related videos on Youtube

user155695
Author by

user155695

Updated on September 17, 2022

Comments

  • user155695
    user155695 almost 2 years

    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

    • Shekhar
      Shekhar over 13 years
      Use different port numbers like localhost:1111 , localhost:2222
    • user155695
      user155695 over 13 years
      I want to use different hostnames not different ports
  • user1686
    user1686 over 13 years
    You can put multiple hostnames in a single address line.
  • Linker3000
    Linker3000 over 13 years
    True - I put them on separate lines as its quick and easy to comment them in and out as needed.
  • J.Do
    J.Do over 3 years
    @Linker3000 Is there a way to access that host on a different PC that's connected to the same network via VPN? I connect to my work VPN and this would give access to my server on my home PC via IP or the server name servername.org.com and this works fine on a browser. I've added a new host under that file 127.0.01 test555.com. On the server I can RDP to can access it on the browser with the provider name there but if I was to do it on my home PC, still connected to the VPN, it does not work. Is this possible?