Article Title: How to Create a DNS server on Linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
I. Environment assumptions
One or two machines, one LINUX, The Machine name LINUX, the domain name tongqiang. cnIP address is 192.168.0.5, the other machine is WIN98, The Machine name tongqiang, And the IP address is obtained from the DHCP server on LINUX.
2. Create a DNS server (assuming that your DNS software package has been installed and you choose to install the DNS server when installing LINUX)
To create a DNS server, you only need to modify the following files.
1 named. boot or named. conf (Note: In versions earlier than RedHatlinux5.2, You need to modify named. boot. In Versions later than RedHatlinux5.2, You need to modify named. conf.
The modified content is as follows)
; Boot file for name server
Directory/var/named (specify to read DNS database files from the/var/named directory, such as forward parsing files, reverse parsing files, local files, and cache files under this directory)
Primary tongqiang.cn. db (it indicates that the domain resolved by the primary DNS server is tongqiang.cn, And the DNS database file is tongqiang.cn. db)
Primary 0.0.127.in-addr. arpa db.127.0.0.0 (specify the DNS database file for internal address translation resolution)
Primary 0.168.192.in-addr-arpa db.0.168.192 (specifying reverse DNS database file resolution)
Cache. db. cache (specify the address file for obtaining the "root" server from the internet)
3. Create Database Files respectively
1. Create a forward DNS database file and enter the directory/var/named.
Vi tongqiang.cn. db
(Contents of the following files)
@ In soa linux.tongqiang.cn. root.linux.tongqiang.cn. (199511301
28800
7200
3600000
86400)
NS linux.tongqiang.cn.
Mx 10 support.tongqiang.cn
Localhost A 127.0.0.1
Linux A 192.168.0.5
Www cname linux.tongqiang.cn.
In the above DNS database file, the first line indicates the name of the DNS server, the email address of the DNS administrator, and the first number indicates the version number, after each modification, you must add a version number, that is, simply add 1 to the file. The NS record specifies the Domain Name of the Domain Name Server, the MX record specifies the mail address conversion record, and the record is the address record, indicating the relationship from the domain name to the IP address. CNAME is an alias record, which maps www.tongqiang.cn to linux.tongqiang.cn.
Note that the relative domain name and absolute domain name above are represented, that is, some domain names are followed by DOTS (.), Some do not add (.). That is, the domain name after the alias record and MX record must be added.
2. Create a reverse database resolution file (db.0.168.192)
@ In soa linux.tongqiang.cn. root.linux.tongqiang.cn .(
199511301
28800
7200
3600000
86400)
NS linux.tongqiang.cn.
5 PTR linux.tognqiang.cn.
The above meaning is similar to the forward resolution, but PTR is used for reverse resolution record.
3. Create db.127.0.0.0
@ In soa linux.tongqiang.cn. root.linux.tongqiang.cn .(
199511301
28800
7200
3600000
86400)
NS linux.tongqiang.cn.
1 PTR localhost
The meaning is the same as above.
4. You can download the db. cache file from ftp.rs.internic.net. Change the downloaded file to db. cache.
4. Start and test named
Use ndc start
Then run the nslookup command to display a command prompt. When checking for forward resolution, you can directly enter a prompt such as linux for query, or enter 192.168.0.5 for reverse resolution. When checking aliases and MX records, enter set q = cname and set q = mx, and then enter www.tongqiang.cn and email address respectively.
5. the version number must be added after the database record is modified. Do not forget to modify the reverse resolution file, and then use ndc reload to reload the database file.
6. This experiment is very simple. If there are other network segments in the domain and the DNS settings when you connect to the Internet through the ISP, see "Supplemental DNS settings".