I. Overview:
DNS: domain name system, domain name system. Internet, as a distributed database that maps domain names and IP addresses, allows users to access the Internet more conveniently without remembering IP addresses.
The process of obtaining the IP address corresponding to the host name through the host name is called domain name resolution (or host resolution ). DNS runs on UDP and listens to port 53.
Generally, the domain name of an Internet host is globally unique. The general structure is 650) This. width = 650; "Title =" image "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; padding-right: 0px "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/2/2664956_1404317041ajqa.png "" 244 "Height =" 103 "/>
DNS resolution type: FQDN (Fully Qualified Domain Name)-> forward IP resolution FQDN <-reverse IP resolution
DNS name resolution library in Linux:/etc/named text file: each row is called a resource record type: FQDN-> IPv4: afqdn-> IPv6: aaaadomain-> DNS server: NS (Name Server) domain-> master DNS: SOA (start of authority) FQDN-> FQDN: cname (canonical name) IP-> FQDN: PTR (pointer) domain-> MX (mail exchange), with a priority (0-99), the smaller the number, the higher the priority IP-> FQDN :. inaddr. ARPA
2. Establish DNS forward resolution:
1. Install the Bind package: Yum install-y bind;
2. Run rpm-QC bind to view the file generated by the BIND installation;
[[email protected] ~]# rpm -qc bind/etc/logrotate.d/named/etc/named.conf/etc/named.iscdlv.key/etc/named.rfc1912.zones/etc/named.root.key/etc/rndc.conf/etc/rndc.key/etc/sysconfig/named/var/named/named.ca/var/named/named.empty/var/named/named.localhost/var/named/named.loopback
3. Modify the main configuration file/etc/named. conf;
// listen-on port 53 { 127.0.0.1; };// listen-on-v6 port 53 { ::1; };// allow-query { localhost; };
Add the three rows in front of the configuration file //
4. modify the configuration file/etc/named. rfc1912.zones and add a new area at the end of the file;
zone "magine356wj.com" IN { type master; file "magine356wj.com.zone";};
5. Create a region file;
[[email protected] ~]# cd /var/named[[email protected] named]# vim magine356wj.com.zone
$TTL 600@ IN SOA dns admin.magine356wj.com,. ( 2014070201 2h 10m 7d 12h) IN NS dns IN MX 10 maildns IN A 192.168.1.199www IN A 192.168.1.198www IN A 192.168.1.197www IN A 192.168.1.196mail IN A 192.168.1.195ftp IN CNAME www
Note: @ indicates the magine356wj added to named. rfc1912.zones;
6. Modify the File Permission;
[[email protected] named]# ls -ltotal 32drwxrwx---. 2 named named 4096 Jan 20 12:40 datadrwxrwx---. 2 named named 4096 Jan 20 12:40 dynamic-rw-r--r--. 1 root root 252 Jun 29 08:53 magine356wj.com.zone-rw-r-----. 1 root named 1892 Feb 18 2008 named.ca-rw-r-----. 1 root named 152 Dec 15 2009 named.empty-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost-rw-r-----. 1 root named 168 Dec 15 2009 named.loopbackdrwxrwx---. 2 named named 4096 Jan 20 12:40 slaves[[email protected] named]# chmod 640 magine356wj.com.zone [[email protected] named]# chown :named magine356wj.com.zone [[email protected] named]# ls -ltotal 32drwxrwx---. 2 named named 4096 Jan 20 12:40 datadrwxrwx---. 2 named named 4096 Jan 20 12:40 dynamic-rw-r-----. 1 root named 252 Jun 29 08:53 magine356wj.com.zone-rw-r-----. 1 root named 1892 Feb 18 2008 named.ca-rw-r-----. 1 root named 152 Dec 15 2009 named.empty-rw-r-----. 1 root named 152 Jun 21 2007 named.localhost-rw-r-----. 1 root named 168 Dec 15 2009 named.loopbackdrwxrwx---. 2 named named 4096 Jan 20 12:40 slaves
7. check;
# Named-checkconf
# Named-checkzone "maine356wj.com"/var/named/magine356wj.com. Zone
[[email protected] named]# named-checkconf[[email protected] named]# named-checkzone "magine356wj.com" /var/named/magine356wj.com.zone zone magine356wj.com/IN: loaded serial 2014070201OK
8. Start the service;
650) This. width = 650; "Title =" image "style =" border-top: 0px; border-Right: 0px; Background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; border-left: 0px; padding-right: 0px "border =" 0 "alt =" image "src =" http://img1.51cto.com/attachment/201407/2/2664956_1404317041exGR.png "" 244 "Height =" 35 "/>
9. Modify default DNS
Vim/etc/resolv. conf
Nameserver = 192.168.1.151 (modify the local IP address)
10. Test
[[email protected] named]# dig -t A www.magine356wj.com ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> -t A www.magine356wj.com @192.168.1.153;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41789;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 1, ADDITIONAL: 1;; QUESTION SECTION:;www.magine356wj.com.INA;; ANSWER SECTION:www.magine356wj.com.600INA192.168.1.197www.magine356wj.com.600INA192.168.1.196www.magine356wj.com.600INA192.168.1.198;; AUTHORITY SECTION:magine356wj.com.600INNSdns.magine356wj.com.;; ADDITIONAL SECTION:dns.magine356wj.com.600INA192.168.1.199;; Query time: 2 msec;; SERVER: 192.168.1.153#53(192.168.1.153);; WHEN: Sun Jun 29 09:25:45 2014;; MSG SIZE rcvd: 119