Implement remote configuration of the DNS system under Linux

  




Because Linux is a Unix-like operating systems, operating system management is a cumbersome process. The development of the Internet has brought us a simple computing operation platform. Its application has spread all over the fields of scientific research and teaching, enterprise e-commerce and online life. Web technology enables the information transmission of the Internet to be faster and faster, and thin customers. The computer's computational model has been widely used in the Internet. If we can transplant Linux system management to the Web computing platform, the burden on Linux system administrators will be greatly reduced, and Linux system management will be facilitated. At the same time, due to the distributed computing features of the Web, the management of the system is not limited by geography, and the remote management of the Linux system can be conveniently implemented.

In view of the above analysis, I will implement a simple Linux DNS domain name remote management system based on Linux Web platform. Because Sun's Sparc chip has better server performance than PC and the bus is 64-bit, we use Sparc machine as the server and use the 64-bit Chinese Linux Penguin64 operating system as the hardware environment of the system.

Remotely call DNS principle analysis with CGI:

1) This system is in the form of a web page, so that users can configure it on any host that can connect to the server. We can use php or perl Writing cgi program, writing with php is relatively simple, it is easy to get started, but considering the use of cgi to call DNS commands, using perl is more conducive to operation, so use perl to write. Use cgi to call DNS commands and configuration files, directly The configuration file is rewritten and saved to make the DNS server work.

2) The following can be used to analyze the process of the cgi program calling DNS to configure according to the chart and the screenshot:

Several important modules of the system:


web-lib.pl: This module directly defines the functions that other modules of the system need quickly.
For example: PrintHeader Print HTTP stream of Header
header(title) Output a page header with a header
There are also read, find, and other functions.
records-lib.pl: This module stores some information about the record. Processing function
such as saving records, creating, deleting records and other functions.
bind8-lib.pl: This module stores the basic function of the configuration file operation in bind8
(bind8 here refers to DNS)
create_master.cgi: This module is used to create a new primary domain.
master_form.cgi : This module creates a new primary domain
edit_master_zone.cgi: This module edits the options of the existing primary domain And structure.
save_master.cgi : This module saves the change of the main domain option to named.conf.
edit_text.cgi: This module displays and modifies a table structure for manually editing the log file.
save_text .cgi: This module saves a manually edited domain file.
edit_record.cgi: This module edits an existing record type.
save_record.cgi: This module adds or updates certain types of records
delete_zone.cgi: This module deletes an existing primary domain , from the domain or the forwarding domain, and its log file.
dns_boot.cgi: This module creates an empty named.conf file and redirects to index.cgi.
start.cgi: This module starts bind8
restart.cgi: This module restarts the running program named
index.cgi: This file is the home page of the user login. Users can select the domain to create or edit DNS on this page. The file then calls the above modules.
Block operation.

System running process:

On the index.cgi home page, you can create a primary domain, edit the primary domain or add modified SOA information. The user clicks to create a primary domain. After entering the next page master_form.cgi, the user fills in the created information on this page:

After filling in the information, click Save. At this point, the system calls create_master.cgi, and the information filled in by the user is in /etc/Add a line of information to named.conf such as:


zone "guhang.com"{
type master;
file "www.guhang.com";
};
(DNS's named.conf file configuration, as already mentioned above)

Meanwhile, create_master.cgi is Create a www.guhang.com log file in the /var/named/directory. Explain in detail the information in the "guhang.com" field. After the creation, the system returns to the index.cgi page and waits for the user to edit the domain information.

After returning to the main page, the user can click on the main domain just created, such as: www.guhang.com, and call the edit_master.cgi page to add information to the main domain or modify its contents.

Users can click on each option icon on this page to configure, you can add the host address in the domain, the address of the name server, the address of the mail server, etc.,

Then call edit_recs.cgi The filled in information is created and displayed on the page, and save_record.cgi is saved to the "www.guhang.com" file in the /var/named/directory to generate the following main domain interpretation information:


@ IN SOA guhang.com. hostmaster.guhang.com. (
1997022700 ; serial
28800 ; refresh
14400 ; retry
3600000 ; expire
86400 ; Default_ttl
)
@ IN NS www.guhang.com.
@ IN MX 10 mj.guhang.com.
localhost IN A 127.0.0.1
mj IN A 192.192.192.35
song IN A 159.226.4.200
zou IN A 159.226.4.211
www IN A 192.192.192.35
#www IN CNAME @

To save information on the entire edit_master.cgi page Call save_master.cgi to save and return to the edit_master.cgi page. To delete the primary domain information, delete_main.zone is used to record the entire primary domain. The department deletes and returns to index.cgi to wait for the user to add new information.

This modification is the same as manual configuration in the linux console, and then save the restart name can work. After the configuration is complete You can access the domain of www.guhang.com.

Summary:

Calling DNS through CGI for configuration does make it easy to operate, easy to configure, and can not be restricted to the server. It is much more convenient to manually configure it under the Linux console, but this also requires the configuration personnel to have a certain understanding of the DNS principle. It is best to manually configure the DNS server because CGI will write your configuration information. Into, BIND8 configuration file, call the BIND8 command only. We can also bypass the class, use CGI for Apache, Sendmail, Dhcp, Ftp, even Linux users, file configuration and management operations. Of course, we can use the shell , c, etc. to write CGI can also call Linux command operations, but because Perl is a powerful super-shell language, it is more convenient to write in Perl, but because of Perl's grammar rules, It is difficult to understand the part of regular expression and pattern matching, so there are some loopholes and incomprehensible in the process of writing. Due to the short time, it is not deep enough for Perl to understand, which will inevitably lead to mistakes in future development. Modify and enhance.

Explanation of terms:


Noun description
HTML Hypertext Markup Language, hypertext link markup language.
C /S Client /Server, client /server mode.
SQL Structured Query Language, structured query language.
Samba A set of programs that enable your Linux to understand the SMB protocol (Server Message Block, a widely used protocol in the Windows family of OS/2, Windows NT, Windows 9x and Windows for workgroups, which is widely used. Mainly used to achieve the ability to share files and printers.
DNS Domain Name Server, a domain name server that provides name resolution services for computer networks.
SMTP Simple Message Transfer Protocol, a simple mail transfer protocol for the transmission of e-mail.
POP Post Office Protocol, post office agreement, accepted by email.
One of the network protocols used by the AppleTalk Mac.
ISDN Integrated Services Digital Network, Integrated Services Digital Network.
PPP Peer-Peer Protocol, end-to-end protocol.
SLIP Serial Line Interface Protocol, serial line interface protocol.
ATM Asynchronous Transfer Mode, asynchronous transfer mode.
FTP File Transfer Protocol, file transfer protocol.
DHCP Dynamic Host Configuration Protocol, the dynamic host configuration protocol, allows the host to automatically obtain the basic configuration information (IP, DNS, ...) of the machine from the network.
TCP/IP TCP: Transfer Control Protocol, Transmission Control Protocol.
IP: Internet Protocol, Internet Protocol.
NFS Network File System, network file system.
CGI Common Gateway Interface, a common gateway interface.
Java A new type of object-oriented computer programming language, widely used in the Internet and embedded system design.
Perl Practical Extraction and Report Language, a programming language on Unix systems.
POSIX Portable Operating System Interface, portable operating system interface.
GUI Graphics User Interface, graphical user interface.




Copyright © Windows knowledge All Rights Reserved