Access a named webserver using a different IP address

From BigSoft
Jump to: navigation, search

[edit] Problem

In some cases you want to work on a website before the domain name has been created. The domain name service (DNS) contains all the name to IP address translations so for example www.bigsoft.co.uk translates into a "real address" in the form n.n.n.n where n is a number between 0-255. Adding names or translations can take a couple of days while the name transfers around the DNS machines across the world. If there are translations in those DNS machines already then they will time-out after a day or two and pick up the new one.

[edit] Process

  • Launch notepad: Start->Run. type "notepad" (without the quotes)
  • Navigate to c:\WINDOWS\system32\drivers\etc or c:\WINNT\system32\drivers\etc depending on your OS
  • Load a file called hosts
  • You will see something like:
# Copyright (c) 1993-1999 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
127.0.0.1       localhost
  • Add a line to the bottom in a similar form to the others e.g.:
# Copyright (c) 1993-1999 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
127.0.0.1       localhost
1.2.3.4         www.mydomain.co.uk mydomain.co.uk ftp.mydomain.co.uk
  • Replace 1.2.3.4 with the address you want your name to point to, and obviously change mydomain.co.uk to your domain name
  • Save the file then try to access the website in your browser again.
  • You should now go to the new address.
  • After you have finished your testing don't forget to remove the line you just added from the hosts file.

If you will be doing this a lot of times then you may want to comment out the line so that it has no effect. The comment character is a hash (#), so you can edit the hosts to look like:

# Copyright (c) 1993-1999 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
127.0.0.1       localhost
#1.2.3.4         www.mydomain.co.uk mydomain.co.uk ftp.mydomain.co.uk
Personal tools