How to develop a virtual domain name system Author: Anonymous
Everyone is very convenient when using a brief name such as Yourname.yeah.Net, and many people are thinking: I can make my own server can achieve a brief domain name. In fact, this is not complicated. After reading this article, you can also make a brief domain name system.
The key technique of a briefed domain name system is to implement the redirect of the web page. In essence, a brief domain name system and virtual machine system are completely different. The virtual domain name and IP of the virtual machine exist one part of the relationship. A briefn domain name system does not need to map the domain name and IP. That is, it does not require a complex domain name parsing mechanism and virtual machine to do, what it does is where you are requesting your browser to you to store your HTML page when you ask YourName.Somain.
For more complete, the following episode:
The source program I provide is that the operating environment is: Redhat 5.1 under the Apache1.3.6 Web Server PHP3 language. Before writing the program, we must first set our server. First let the Apache server support php3. To ftp.redhat.com download mod_php-2.0.1-9.i386.rpm, after installation, modify the /etc/httpd/conf/http.conf file, remove the #LOADModule PHP3_MODULE # 注释 号, also in / ETC The / httpd/conf/srm.conf file removes the annotation number in front of the #addtype application / x-httpd-php3 .php3 while adding index.php3 after DirectoryIndex. Restart Apache Server, at which time the server supports standard PHP3 language script files and can use Index.php3 as the default home.
Set the DNS server to make it resolved in the general domain name. The general Unix and Linux systems DNS parses are completed by the Bind daemon, Bind4 and Bind8 profiles separate /tc/named.boot and name.conf, and modify it according to your system. Set Bind's profile /etc/named.boot, add a new domain record in which "Primary Domain.com DB.Domain" is added. Add: in /etc/name.conf:
ZONE "domain.com" {
TYPE MASTER;
File "db.domain";
}
Newly built the main domain record file DB.Domain in / var / name / zone, its format is:
N soa dns.domain.com Root.domain.com
199811291; Serial
28800; Refresh
7200; RETRY
604800; EXPIRE
86400); Minimum
DNS
MX 10 DNS.DOMAIN.com.
DNS A 202.115.135.50
WWW A 202.115.135.50
* A 202.115.135.50
The key is the last sentence, all HostName that may appear in the entire domain may point to the same IP. Execute / USR / SBIN / NDC RELOAD, reload the domain name database. Test it, you should pick up a host in a Domain domain (in addition to the marked), all points to the specified IP, then the DNS server setting is completed.
The final step is to prepare a PHP3 script. We have just explained the entire principle in detail in the figure, so writing a re-directional program is not very difficult.
Let's take a full http header information sent by IE5.0:
Accept: Application / VND.ms-Excel, Application / Msword, Application / VND.MS-PowerPoint, Image / GIF, Image / X-Xbitmap, Image / JPEG, Image / PJPEG, * / * Accept-Encoding: Gzip, Deflate
Accept-language: zh-cn
Connection: Keep-alive
Host: ww.yahoo.com
User-agent: mozilla / 4.0 (compatible; msie 5.0b1; windows 98)
We need to remove Host information throughout the HTTP header, then http://www.jj.jx.cn/www.xxx.xxx/default.htm form "www", ie Hostname (ie user The registered Name is removed separately as a keyword to redirect retrieval.
After retrieving the URL information registered by the user, we give the user browser to a redirected command "localtion: http://www.jj.jx.cn/somewhere/sample.html", redirect the user to the specified page.
In PHP3, there is a function getAllHeader (), get the HTTP header information sent by the browser. We mainly need to use this function to complete the entire program.
The rear came from the source program, since it is only experimental nature, when the user information is queried, there is no database. If the entire system is actually applied, it must be hooked with the database, otherwise the process of querying the user information will be very long. It greatly affects efficiency, and the management of user data is not convenient. (Due to the constraint, no write records required for registration and management, please add it yourself)
In the source program, all user information is recorded in the User.dat file in the Data subdirectory. The format is:
Username:
Http://octopus.cdit.edu.cn/~qap213/index.html
Attached PHP3 source:
File: // Get http's header and parse it //
$ headers = getAllHeaders ();
While (List ($ header, $ value) = Each ($ headers)) {
IF ($ header == "host") {$ usrname = strtok ($ value, ".");}}
File: // jump out the banner's window //