Showing posts with label DNS. Show all posts
Showing posts with label DNS. Show all posts

Tuesday, June 5, 2012

Virtual Host: multiple domain names on a machine Part I

PIN code is an address identifier to your location , Similarly an IP address , is an address that identifies a machine , Most of the interaction of a user to any machine is based on IP address.

Domain name service lets you map a Domain Name with an IP address , which means one can use a simple to remember a domain name and not remember the IP address. A server is usually a costly resource so what a hosting company simply does is hosts multiple domains on one machine. This way they can simply give a slice of hard disk space of a machine to a single user. This way an expensive resource can be utilize to maximize profits.

Lets see how you can do it , with Apache Virtual host configuration. This is not a post on automatic virtual configurations.

There are two ways of doing this one is the hard way:
  1. Create a new file in folder 
    1. /etc/apache2/sites-enabled
    2. Paste in following code 
    3. <VirtualHost *:80>
        DocumentRoot /home/shyam/workone/
          ServerName workedhost
            <Directory "/home/shyam/workone/">
              allow from all
                Options +Indexes
                  </Directory>
                    </VirtualHost>

                  1. at this point simply do
                    sudo a2ensite nameofthefile or
                    simply do a symlink of this file in site-enabled folder in /etc/apache2
                    works in ubuntu this way
                  2. Lets analyse this perticular code 
                The first line virtualhost directive  with * which signifies the address on which this domain name will be processed , In this case its any address associated with the servers ip address

                Now the next thing is :80 , his signifiies the port on which the hosting is going to be done 


                After this you have a directive called the DocumentRoot

                This directive shows where the server files are going to be stored
                Now lets look at the directory directive :

                With this we have attribute thats showing a path to DocumentRoot directory , This is done so we could apply some rules to this directory ,
                Current rules are

                apply from all , this allows all host names to access this files
                Options +Indexes Means it will look for default index file in the perticular directory


                Now you are ready to have a virtual host in ubuntu


                In case of any other OS , you could try putting this in Apache.conf(windows) or httpd.conf(fedora) file

                Of you could simply write this in a file and load it  with
                 Include "relative or absolute path to file"


                This in the first , or what i call manual case , Lets cover how to do it easy using a tool called webmin , Make sure you keep and Eye out for that post , You will see lots of things that can be done easily with out any hassle

                Thursday, May 17, 2012

                Hosts file : DNS server for local machine

                In age of internet , one who does not have domain name , does not have existence. This was line i heard in a movie, Cool as it sounds not really true yet , but eventually may become true.

                DNS , Domain Name System , was introduced to identify as machine with a name that one can remember  , and not a machine readble  address like "127.0.0.1" . While its just set of 4 numbers , a name like google.com is always easier to remember than 173.194.36.49. See what I mean ?


                 Domain name system works for the whole internet  , But one can make such a thing just for one's computer , This is done by something called a hosts file. Every Operating system has it , usually in a folder called etc , Although this folder can be deep within in your system. but this file does exist.


                Lets us see how we can use this file to do things we want to do.


                Lets say you want to play a naughty joke on your friend , so when he types in www.yahoo.com , you want him to see google.com , Here is how you can do that.

                1. First you need access to the machine on which you want to play this joke.
                2. Find the hosts file locations are specified below 
                  1. Windows
                    usually located on C:\windows\System32\drivers\etc\
                  2. Mac and Linux
                    Usually located in /etc/ folder in root 
                3. Now open the file in administrator privilege
                  and now add entries to it so that you can stick yahoo to may be something like google.com
                4. Now save and watch the magic happen
                here is a pictographical walkthru

                1. Open hosts file using a text editor , In linux you may have to run this command with sudo

                2. Open the hosts file using the text editor

                3. Now edit the file to map the domain name





                4. Now for the result


                Please do comment :)

                Any suggestions to make this more easier to understand will be appreciated.