In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "Linux system DNS configuration tutorial", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and study the "Linux system DNS configuration tutorial" bar!
Task 1: build a primary domain name server
Task 2: build a secondary domain name server
Task 3: test the DNS service
Task 4: configuration and testing of cached DNS services
Configuration of task 5:DNS transponders
Task 6: create new subdomains and subdomain delegates.
Set up two virtual machines
1.#ifconfig
2.#netconfig
3.ip address 192.168.13.1
Netmask: 255.255.255.0
Default gateway: 192.168.13.154
Primary nameserver: 192.168.13.1
4.# service network restart
5.ifconfig
6.rpm-ql | grep bind
-- check out the installed dns-related packages.
Bind-utils-9.2.4-2
Ypbind-1.17.2-2
Bind-6.2.4-2
Bind-libs-9.2.4-2
7.#rpm-qa | grep caching
Caching-nameserver-7.3-3
8.#rpm-ql caching-nameserver
You can see as many as eleven files.
There are master configuration files and zone files.
/ var/named/named.ca-- list of root domain servers currently on the Internet.
9.#service named start
10.#cat / var/named/named.ca
We now configure the primary dns server.
1.ll / etc/named.conf
-rw-r--r-- 1 root root 1323 Aug 26 2010 / etc/named.com
2.ll / var/named/
-- you can see nine files
3.vi / etc/named.conf
Six configurations are used by default.
We copy.
Zone "localhsot" IN {
Type master
File "localhost.zone"
Allow-update {nane;}
}
Zone "0.0.127.in-addr.arpa" IN {
Type master
File "localhost.zone"
Allow-update {none;}
}
Paste it below and modify the domain name and area.
Zone "xapc.com" IN {
Type master
File "xapc.com.zone"
Allow-update {none;}
}
Zone "13.168.192.in-addr.arpa" IN {
Type master
File "xapc.com.rev"
Allow-update {none;}
}
: wq
4.#clear
5.#cd / var/named
6.#ll
7.#cp localhost.zone xapc.com.zone
8.#cp named.local xapc.com.rev
9.#vi xapc.com.zone
We need to modify the configuration in it.
@ IN SOA root (
42; serial (d.adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
IN NS @
IN A 172.0.0.1
IN AAAA:: 1
-this is the system default configuration. We're going to fix it.
@ IN SOA dns1.xapc.com. Root.xapc.com. (
42; serial (d.adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
IN NS dns1.xapc.com.
IN NS dns2.xapc.com.
IN MX 5 mail.xapc.com.
Dns1 IN A 192.168.13.1
Dns2 IN A 192.168.13.2
Www IN CNAME dns1.xapc.com.
Ftp IN CNAME dns2.xapc.com.
Mail IN CNAME dns2.xapc.com.
: wq
10.#vi xapc.com.rev
@ IN SOA localhost.root.localhost. (
132323232; Serial
28808; Refresh
14400; Retry
3600000; Expire
86400); Mimimum
IN NS localhost.
1 IN PTR localhost.
-the above is the default configuration, which we are going to modify.
@ IN SOA dns1.xapc.com root.xapc.com. (
132323232; Serial
28808; Refresh
14400; Retry
3600000; Expire
86400); Mimimum
IN NS dns1.xapc.com.
IN NS dns2.xapc.com.
1 IN PTR dns1.xapc.com.
1 IN PTR www.xapc.com.
2 IN PTR dns2.xapc.com.
2 IN PTR ftp.xapc.com.
: wq
11.# named-checkconf
If there is no hint, it is successful.
12.# named-checkzone xapc.com xapc.com.zone
13.#service named restart
14.#nslookup
> service 192.168.13.1-contact me.
15.#ifconfig
16.#ping 192.168.13.1
17.#netstat-ntl
18.#cat / etc/resolv.conf
Nameserver 192.168.13.1
19.#nslookup www.xapc.com
Server: 192.168.13.1
Adderss: 192.168.13.1#53
Www.xapc.com cononical name = dns1.xapc.com.
Name: dns1.xapc.com
Address: 192.168.13.1
20.#nslookup ftp.xapc.com
Server: 192.168.13.1
Adderss: 192.168.13.1#53
Ftp.xapc.com canonical name = dns2.xapc.com.
Name: dns2.xapc.com
Address: 192.168.13.2
-forward analysis of all the above.
-the reverse phase analysis begins now.
21.nslookup 192.l68.13.2
Server: 192.168.13.1
Address: 192.168.13.1#53
2.13.168.192.in-addr.arpa name = ftp.xapc.com.
2.13.168.192.in-addr.arpa name = dns2.xapc.com.
22.cat / etc/resolv.conf
Nameserver 192.168.13.1
-save it in this file by default, and look for it in this file.
23.#ping dns1.xapc.com
24 # nslookup
> server ip address-- here you can change the DNS server temporarily.
> set type=mx
> xapc.com
Server: 192.168.13.1
Address: 192.168.13.1#53
Xapc.com mail exchamger = 5 mail.xapc.com.
> set type=a
> mail.xapc.com
Server: 192.168.13.1
Address: 192.168.13.1#53
Mail.xapc.com comomical name = dns2.xapc.com.
Name: dns2.xapc.com
Address: 192.168.13.2
> exit
The above is the forward and reverse configuration.
Second: now let's configure the secondary server.
All right, let's get into the second virtual machine.
1.#ifconfig
2.#netconfig
Ip address: 192.168.13.2
Netmask: 255.255.255.0
Default gateway: 192.168.13.254
Primary nameserver: 192.168.13.2
3.#service network restart
4.#ifconfig
5.#ping 192.168.13.1
6.# rpm-qa | grep bind
Bind-utils-9.2.4-2
Ypbind--1.17.2-3
Bind-9.2.4.4-2
Bind-libs-9.2.4-2
7.#rpm-Q cachimg-nameserver
Cachim-nameserver-7.3-3
8.vi / etc/named.conf
Zone "localhsot" IN {
Type master
File "localhost.zone"
Allow-update {nane;}
}
Zone "0.0.127.in-addr.arpa" IN {
Type master
File "localhost.zone"
Allow-update {none;}
}
-this is its default configuration, and we want to add configuration content.
Zone "xapc.com" IN {
Type slave
File "slaves/xapc.com.zone"
Masters {192.168.13.1;}
}
Zone "13.168.192.in-addr.arpa" IN {
Type slave
File "slaves/xapc.com.rev"
Masters {192.168.13.1;}
}
: wq
9.#ll / var/named/
-- you can see nine files
10.#ll / var/named/slaves/
Total 0
11.#service named start
12.#ll / var/named/slaves
-rw---- 1 named named 436 xapc.com.rev
-rw---- 1 named named 424 xapc.com.zone
13.#nslookup ftp.xapc.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Ftp.xapc.com canonical name = dns2.xapc.com.
Name: dns2.xapc.com
Address: 192.168.13.2
14.#nslookup 192.168.13.1-reverse parsing
Server: 192.168.13.2
Address: 192.168.13.2#53
1.13.168.192.in-addr.arpa name = www.xapc.com.
1.13.168.192.in-addr.arpa name = dns1.xapc.com.
Whether we can do some areas I am auxiliary, some areas I am the primary server.
We're going to do the next experiment.
1.#vi / etc/named.conf
Zone "xapc.com" IN {
Type slave
File "slaves/xapc.com.zone"
Masters {192.168.13.1;}
}
Zone "13.168.192.in-addr.arpa" IN {
Type slave
File "slaves/xapc.com.rev"
Masters {192.168.13.1;}
}
This is the result of the previous configuration, and we are going to add the configuration now.
Zone "pcgj.com" IN {
Type master
File "pcgj.com.zone"
Allow-update {none;}
}
: wq
2.# cd / var/named
3.#ll
4.#cp localhost.zone pcgj.com.zone
5.#vi pcgj.com.zone
@ IN SOA @ root (
42; serial (d.adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
IN NS @
IN A 172.0.0.1
IN AAAA:: 1
-this is the system default configuration. We're going to fix it.
@ IN SOA dns.pcgj.com. Root.pcgj.com. (
42; serial (d.adams)
3H; refresh
15W; retry
1W; expiry
1D); minimum
IN NS dns.pcgj.com.
Dns IN A 192.168.13.2
: wq
6.#service named restart
7.#nslookup dns.pcgj.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Name: dns.pcgj.com
Address: 192.168.13.2
8.#nslookup dns1.xapc.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Name: dns1.xapc.com
Address: 192.168.13.1
Now the problem of reverse parsing. So it will be configured on the main server.
9.#vi / xapc.com.rev
Only one line of configuration is added.
2 IN PTR dns.pcgj.com.
Note: 132323232; Serial should be changed to 132323233; Serial should add'1' to the new configuration so that it can be updated.
: wq
10.#service named restart
11.#nslookup 192.168.13.2
Server: 192.168.13.1
Address: 192.168.13.1#53
2.13.168.192.in-addr.arpa name = ftp.xapc.com.
2.13.168.192.in-addr.arpa name = dns2.xapc.com.
2.13.168.192.in-addr.arpa name = dns.pcgj.com.
Now we are going back to the client:
12.#cat slaves/xapc.com.rev
Configuration files that can be viewed
Such as:
2 PTR dns.pcgj.com.
PTR ftp.xapc.com.
PTR dns2.xapc.com.
13.#nslookup 192.168.13.2-reverse parsing
Server: 192.168.13.2
Address: 192.168.13.2#53
2.13.168.192.in-addre.arpa name = ftp.xapc.com.
2.13.168.192.in-addre.arpa name = dns2.xapc.com.
2.13.168.192.in-addre.arpa name = dns.pcgj.com.
14.#nslookup dns.pcgj.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Name: dns.pcgj.com
Address: 192.168.13.2
All right, then!
Now we're going to do a new experiment.
Forwarding of DNS
We still configure it on the secondary dns server
1.#service named stop
2.#ll
3.vi / etc/name.conf
We are going to add two forwarding configurations, and we also need to delete the configuration for scientific research parsing. Keep only "pcgj.com" because he can't parse the server.
Statistics-file "/ var/named/data/name_stats.txt"
Forward only
Forwarders {192.168.13.1;}
: wq
If you don't rest assured, we can check to see if there are any mistakes.
4.#named-checkconf
5.#service named restart
This computer is no longer a secondary DNS server
6.# ll
7.#ll slaves/
You can see two configuration files.
8.#rm slaves/*
9.# nslookup www.xapc.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Nom-authoritative answer;--- is not authoritative.
Www.xapc.com camomical name = dns1.xapc.com.
Name: dns1.xapc.com
Address: 192.168.13.1
10.#nslookup dns.pcgj.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Name: dns.pcgj.com
Address: 192.168.13.2
Can we get part of the region to forward, two domains, I'll let this area forward to you, other domains, I can find the root.
We also modify the configuration file on the secondary dns.
1.#vi / etc/named.conf
We need to comment out two configurations. Create a new area.
/ / forward only
/ / forwarders {192.168.13.1;}
Zone "xapc.com" IN {
Type forward
Forward only
Forwarder {192.168.13.1;}
}
: wq
2.#service named restart
3.#nslookup ftp.xapc.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Nom-authoritative answer
Ftp.xapc.com camomical name = dns2.xapc.com.
Name: dns2.xapc.com
Address: 192.168.13.2
4.#nslookup 192.168.13.2
It cannot be parsed because it is not forwarded to this area and the root cannot be found.
So we can have one area forward and the other areas find the root.
Main Test methods of DNS Server
We can test the DNS server comprehensively by using special tools such as nslookup,dig and host.
Use nslookup to test DSN server 1
(1) enter the nslookup command exchange environment
# nslookup
>
(2) set to use the specified DNS server
> server 192.168.1.2
(3) Test the forward resolution of localhost host domain name
> localhost
(4) Test the reverse resolution of localhost host domain name
> 127.0.0.1
Practice on the secondary dns:
1.#nslookup
> server 192.168.13.1
Default server: 192.168.13.1
Address: 192.168.13.1#53
> 192.168.13.2
Server: 192.168.13.1
Address: 192.168.13.1#53
2.13.168.192.in-addr.arpa name=dns.pcgj.com.
2.13.168.192.in-addr.arpa name=ftp.xapc.com.
2.13.168.192.in-addr.arpa name=dns2.xapc.com.
> exit
Use nslookup to test DSN server 2
(1) Test domain name resolution on the Internet
> www.yahoo.com.cn
(2) Test the A record in the test.com domain
> host1.test.com
(3) Test the PTR record in the test.com domain
> 192.168.1.11
(4) Test the CNAME record in the test.com domain
> www.test.com
Use nslookup to test DSN server 3
(1) Test the NS record in the test.com domain
> set type=ns
> test.com
(2) Test the MX record in the test.com domain
> set type=mx
> test.com
(3) set up the test of A record
> set type=a
Use the dig command to test DNS server 1
Dig @ dns domain name or ip zone record type
Eg: dig @ 192.168.13.2 xapc.com NS
It means that if you go to the network segment 192.168.13.2 to mine the NS record in this area of xapc.com, the result will show that NS has to be recorded.
Let's demonstrate it on the auxiliary dns.
1.#dig @ 192.168.13.2 xapc.com NS
2.ll / var/name/named.ca
-- saves all the domain name resolution of the root domain server, how to get the dns list file. It is obtained with the dig command.
Dig @ a.root-servers.net. NS > / var/named/named.ca
All right, now we're going to talk about something important.
Delegation of the DNS subdomain.
The two servers are father-son relationship. But each of them has their own dns server to parse.
All right, let's start with the auxiliary dns.
1:#pwd
/ var/named
2: # vi / etc/named.conf
Zone "0.in-addr.arpa" IN {
Type master
File "named.zero"
Allow-update {none;}
}
Zone "pcgj.com" IN {
Type master
File "pcgj.com.zone"
Allow-update {none;}
}
Zone "xapc.com" IN {
Type forward
Forward only
Forwarders {192.168.13.1;}
}
-the above is modified above. We need to delete some configurations.
Some content is added below.
Zone "ca.xapc.com" IN {
Type master
File "ca.xapc.com.zone"
Ailow-update {none;}
}
: ok
We also need to create a new ca.xapc.com.zone file.
2.#ll
3.#cp pcgj.com.zone ca.xapc.com.zone
4.#vi ca.xapc.com.zone
@ IN SOA dns.pcgj.com. Root.pcgj.com. (
42; serial (d.adams)
3H; refresh
15W; retry
1W; expiry
1D); minimum
IN NS dns.pcgj.com.
Dns IN A 192.168.13.2
-this is the file we modified earlier, and we need to modify it.
@ IN SOA dns.ca.xapc.com. Root.ca.xapc.com. (
42; serial (d.adams)
3H; refresh
15W; retry
1W; expiry
1D); minimum
IN NS dns.ca.xapc.com.
Dns IN A 192.168.13.2
Www IN A 192.168.13.1
: wq
5:# service named restart
6:# nslookup www.ca.xapc.com
Server: 192.168.13.2
Address: 192.168.13.2#53
Name: www.ca.xapc.com
Address: 192.168.13.1
Now we come to the main server to see if the main server can parse, can it parse its grandson?
7:#nslookup www.ca.xapc.com
-cannot be parsed, because it is not delegated, so it cannot be resolved.
8:#vi / etc/named.conf
It is time to make delegates without modifying the main configuration file.
All we need to do is modify the resident configuration file of xapc.com.zone.
9:#vi xapc.com.zone
@ IN SOA dns1.xapc.com. Root.xapc.com. (
42; serial (d.adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
IN NS dns1.xapc.com.
IN NS dns2.xapc.com.
IN MX 5 mail.xapc.com.
Dns1 IN A 192.168.13.1
Dns2 IN A 192.168.13.2
Www IN CNAME dns1.xapc.com.
Ftp IN CNAME dns2.xapc.com.
Mail IN CNAME dns2.xapc.com.
-this is what we modified earlier, and we also need to modify this file.
@ IN SOA dns1.xapc.com. Root.xpac.com. (
42; serial (d.adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
IN NS dns.ca.xapc.com.
IN NS dns1.xapc.com.
IN NS dns2.xapc.com.
IN MX 5 mail.xapc.com.
Dns1 IN A 192.168.13.1
Dns2 IN A 192.168.13.2
Www IN CNAME dns1.xapc.com.
Ftp IN CNAME dns2.xapc.com.
Mail IN CNAME dns2.xapc.com.
Dns.ca IN A 192.168.13.2
: wq
10:#services named restart
11:#nslookup www.ca.xapc.com
Server: 192.168.13.1
Address: 192.168.13.1#53
Non-authoritative amswer:
Name: www.ca.xapc.com
Address: 192.168.13.1
Ok, all the experiments have been completed.
Thank you for reading, the above is the content of the "DNS configuration tutorial of Linux system". After the study of this article, I believe you have a deeper understanding of the DNS configuration tutorial of Linux system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.