I Teach PHP.com

Apache Apache1.3 to 2.0
Configuration Basics
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
SSH Clients
Virtual Hosting
links
syllabus
apache-refcard-letter

Bash Bash Shell Tips And Tricks
bash

CSS CSS2 Reference
links
syllabus

DHTML syllabus

HTML Basic HTML Tags
Creating Images
links
syllabus

Linux Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
Linux Basics
SSH Clients
links
mailme

Linux Clusters Cluster Books
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
SSH Clients
syllabus

Linux Security Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
PHP Security
SSH Clients
Security QuickRef
UnixSecurity2.0
syllabus

Linux SysAdmin Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
PHP Security
SSH Clients
Security QuickRef
UnixSecurity2.0
syllabus
show book

Linux for Business Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
syllabus
show book

PHP 4 page DB system
Install Fedora C1
Install Red Hat 7.2
Install Red Hat 7.3
Linux Basics
PHP Security
Password Protect
Perl CGI Problems
Perl vs. PHP
Yahoo Stocks
links
syllabus

PHP for Flash 1-Flash Intro
2-Flash-PHP Form
Flash-PHP FAQ
Linux Basics
SSH Clients
syllabus

Perl Perl CGI Problems
SSH Clients
syllabus

TCP-IP Subnetting Tutorial
links

WML Yahoo Stocks
links
syllabus

cgi-bin

E-MAIL
DNS and Virtual Hosting

DNS and Virtual Hosting

One of the main reasons for running a server is to host multiple domain names on a single computer who can publish content for the web. This can accomplished with a technique known as virtual hosting. However, before it can work, the Internet has to know how to find our computer.

DNS (or Domain Name Services) is a process which associates domain names with the IP addresses of the computers where that domain's files may be found. An IP (or Internet Protocol) address is a 32-bit number which is usually expressed as a group of four decimal numbers, each ranging between 0 and 255 and separated by periods, like 209.129.16.103. It takes 8 binary digits (or "bits") to represent the 256 possibile combinations between 0 and 255. The four groups of these numbers covers the 32 bits used for the IP address.

Although a 32-bit number can represent some 4.3 billion combinations (at one time enough for one for each person on Earth), a large number of these IP addresses are part of reserved numbers so the actual number is much smaller. Originally, these IP addresses were divided into class "A", class "B", and class "C" networks though now a protocol known as Classless Inter-Domain Routing ("CIDR") is used to divide the IP addresses into smaller networks.

When a computer user types in a domain name in his favorite web browser, the computer s/he is working on consults the Domain Name Server which is associated with that computer's Internet Service Provider ("ISP"). Through a complex process, the DNS returns the current IP address for that domain name.  When the browsing computer has the current IP address, it sends a request to that computer for the files requested by the user.  This request includes not only the names of the files requested and the IP address where they should be found but also the domain name entered by the user.  This last part only works on browsers which support HTTP (Hypertext Transaction Protocol) 1.1.  Earlier versions do not support this feature and may have problems with domain names hosted on servers which use virtual hosting.  If an error occurs, such as the file is not found ("404") then the error code is returned to the browser.

A domain name may be reserved through a registrar.  Originally, Network Soloutions.com (aka "InterNIC") was the only place where you could register a domain name.  Now there are many companies who can perform this service.  The resulting competition has led to lower prices for this service.  Using the registrar of your choice (or allwhois.com), check to see if the name you want is already taken.  If it is not, you can register the name with them by supplying personal information about yourself and the primary and secondary Domain Name Server which will be associated with your name.  These DNS servers will act as the authoritative source for your IP address and are usually connected with your Web Hosting Provider as opposed to your ISP.

The people running the DNS will need to have some information so that they can direct the desired traffic to you.  If the DNS is run by your Web Hosting Provider, they will know the IP address of the computer which will contain your web space.  If the computer is run from your home and you have a static IP address, you can inform them of this for this purpose.  It is important to note that servers often have higher traffic than home client computers and your ISP's Terms of Service ("TOS") may prohibit you from running a server.  Business accounts, which usually have static IP addresses, are designed to allow you to run a server though the cost is often nearly double that of a home account.

If you have a running system, as we do with linux.ncc.sdccd.net, we can find out the basic networking information:

ParameterValueHow to get
Server Name: linux.ncc.sdccd.net Type who am i (as 3 words) from the server.
External IP: 209.129.16.103 Use host linux.ncc.sdccd.net from another Linux server
Internal IP: 10.100.1.3 Use /sbin/ifconfig from the server.
Primary DNS: 10.1.1.254 Use cat /etc/resolv.conf from the server.
Secondary DNS: 10.1.1.250 Use cat /etc/resolv.conf from the server.

The figures above relate to the ordinary configuration of this server.  We have made some changes to make this demonstration work.

The domain name we will consider in this demonstration is WebServerClass.com, a name I registered a couple months ago.  The registrar is BulkRegistry.com and the DNS is run by Richard Greenwood at NewTechAdvisors.com.  On Richard's computer is a configuration file, called /etc/named.conf which contains references to indicate that this DNS server is the primary server ("master") for this domain name.  The secondary DNS server ("slave") is located at CTS.com, the site where NewTechAdvisors.com is colocated.  Below is a portion of this file containing some standard entries and the entry for this domain name.

options {
directory "/var/named.new.20001222";
};
zone "." {
type hint;
file "named.ca";
};
zone "0.0.127.in-addr.arpa"{
type master;
file "named.local";
};
zone "42.147.216.204.in-addr.arpa"{
type master;
file "db.42.147.216.204";
};

...

zone "webserverclass.com"{
type master;
file "webserverclass.com";
notify yes;
};

No changes were necessary for this demonstration.  Since this computer is identified as the Primary DNS, a change could be made at a file located at /var/named/webserverclass.com to cause it to point to the new computer.  Below is the original and revised version of this file:

webserverclass.com.     IN      SOA     ns1.newtechadvisors.com. webserverclass.ntadvisors.com. (

                        2001061201
                        86400
                        3600
                        604800
                        432000 )
webserverclass.com.     IN      NS      ns1.newtechadvisors.com.
webserverclass.com.     IN      NS      ns.cts.com.
webserverclass.com.     IN      MX      10 newtechadvisors.com.
webserverclass.com.     IN      A       204.216.147.42

www             IN      CNAME   webserverclass.com.
mail            IN      CNAME   webserverclass.com.
ftp             IN      CNAME   webserverclass.com.
*               IN      CNAME   webserverclass.com.


webserverclass.com.     IN      SOA     ns1.newtechadvisors.com. webserverclass.ntadvisors.com. (

                        2001070201
                        86400
                        3600
                        604800
                        432000 )
webserverclass.com.     IN      NS      ns1.newtechadvisors.com.
webserverclass.com.     IN      NS      ns.cts.com.
webserverclass.com.     IN      MX      10 newtechadvisors.com.
webserverclass.com.     IN      A       209.129.16.103

www             IN      CNAME   webserverclass.com.
mail            IN      CNAME   webserverclass.com.
ftp             IN      CNAME   webserverclass.com.
*               IN      CNAME   webserverclass.com.

The main changes were the IP address and the serial number for the date.  The periods at the end of most of the domain names are important and should not be overlooked.

Once this change was made, we changed the name servers used by the linux.ncc.sdccd.net server so that they would use the new information immediately. Normally, it takes up to several days for this information to be copied to other DNS servers on the Internet.  However, as we can see by using the web browser on the Linux server (lynx webserverclass.com), we get the same web page as we would for (lynx linux.ncc.sdccd.net).

The next step involves making changes to the Linux server so that it will respond properly to this domain name.

 

 


This site contains files and links to support the free courses taught by James D. Keeline at the New Media Center / North City Center through the San Diego Community College District's Centers For Education and Technology.   A list of courses available at the center may be consulted.

The site will be updated throughout the semester both with new content and as a way to try out technologies used in several of the classes. This file modified 14-Jan-2007.