Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I give a name to an IP address? [closed]

Tags:

tomcat6

I am developing a web app using Tomcat. I want to give a name (a domain name) like "google" to access my site.

How can I do that?

like image 276
Manoj Avatar asked May 06 '10 06:05

Manoj


1 Answers

If you only want to give a fake, temporal domain name for demo purposes on your development computer, you can add a line in your hosts file (typically located in /etc/hosts in UNIX/Linux systems):

# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost

# My fake domain name for demo purposes
192.168.1.121   google.com   

Then, when you open the 'google.com' domain name on your computer, it will redirect you to the specified IP address.

Note that this won't work if you want to access your application from other machines. You would have to make the same change in every computer's hosts file for that to happen.

And obviously, you won't be able to access the real google.com website while having that line in your hosts file.

For Windows systems, the only thing that changes is the location of the hosts file (you must be an Administrator to edit this file):

Windows XP/Vista/Windows7:

c:\windows\system32\drivers\etc\hosts
like image 185
Sergio Acosta Avatar answered Sep 22 '22 04:09

Sergio Acosta