Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Map the User Friendly Host Name With Its Corresponding IP Address

DZone's Guide to

Map the User Friendly Host Name With Its Corresponding IP Address

In this article, the author is going to cover how to map the user-friendly host name with its corresponding IP address using Host File in IIS.

Free Resource

Discover 50 of the latest mobile performance statistics with the Ultimate Guide to Digital Experience Monitoring, brought to you in partnership with Catchpoint.

Introduction

In this article, I am going to cover how to map the user-friendly host name with its corresponding IP address using Host File in IIS.

Background

A few days back I got a requirement to change the IP address of our locally hosted website in IIS 8 of Windows server 2012 R2, since it was difficult for the client to remember the IP address every time.

Screen Shot of Expected Output Before Changing host file


Now I am going to change this to some user-friendly name, for ex : www.Karthiksachin.com

Let's see step by step how can we achieve this.

Brief Intro About Host File

What is Host File?

In simple words, Host file is like a telephone directory which will contain the number(IP Address) and associated address(Host Name). So when you give a Host name like www.google.com into your browser, then the Host file is started to see if you have the IP address for that site. If you have, then your computer will get it and act accordingly, otherwise, it will ask the details to the ISP.

Location of Host File in File System

The path to the Host file in Windows is %systemroot%\system32\drivers\etc\ where %systemroot% is usually c:\windows unless you installed Windows on a different partition. So the same can be written as c:\Windows\System32\Drivers\etc\hosts.

Step 1 - To access the host file in Windows 7 you can use the following command in the Run Line to open notepad and the file.

Then it will open the following text file as shown below,

Then it will open the default file like below:

Original File before changing how it looks:

After changing the file as per requirement:

Note: Make sure you have taken the # symbol from that line because it denotes comment.

That's it from the host file point of view.

Now just change following in the IIS, like the screenshots below:


Output

Tried the Same in Window server 2012 R2:

Output:

I hope the above information was a little bit helpful. Kindly share your valuable comments or feedback.

Is your APM strategy broken? This ebook explores the latest in Gartner research to help you learn how to close the end-user experience gap in APM, brought to you in partnership with Catchpoint.

Topics:
iis

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}