Idea:
Global configuration file (with the approximate location of the regional configuration file /var/named) - "Main configuration file (accurately find the regional configuration file /var/named/forward zone and reverse zone files based on the global configuration file) -" Zone Configuration file
Purpose: FTP server planning domain name (within LAN): ftp.long.com 192.168.10.3
There are four types of dns servers: primary server, secondary server, forwarding server, cache server
1. Install the dns server and modify the host IP address
Download the open source free bind, which can help us implement dns service
Start the service and check the status
Here we modify the network card. First we select the network card
Select vmnet1 here
At the same time, the virtual network card also needs to be configured.
Modify network configuration file
Because this host is the server, the IP address of the dns is itself.
Change line 4 to static; change line 15 to yes to automatically start the network card; 17, 18, 19, and 20 can be written according to your own
Restart the network card
2. Modification/etc/named.conf All stations arrangement Text statement
Original file
After modification
The first any (position on line 13) - the network area to monitor
directory (line 15) - Specifyregion configuration file location
dump-file (line 16) - specifybackup file location
The second any (position on line 19) - the range of client IPs that receive dns
The role of dnssec-validation - whether it is affected by selinux (something similar to a firewall)
Line 57 points outMain configuration file
ModifyMain configuration file/etc/named.rfc1912.zones
It has two main functions, the forward zone - resolves domain names into IPs; the reverse zone - resolves IPs into domain names;
We paste and copy the last five lines | (and copy and paste twice; command 5yy, p (one command)), and modify it as follows
The first one is modified into a forward file
zone (zone name) IN { type master; file "Region file name for forward parsing"; allow-update { none; }; };
file "Region file name for forward parsing" - the configuration file here needs to be named and created by yourself (the template for the forward area is name.localhost; for the reverse area, it is name.loopback)
type master——There are three modes: main area (master), root area (hint), auxiliary area (slave)
allow-update { none; };——Whether to update (because I made it locally and will not update it)
The second one is modified as a reverse file
zone "10.168.192.in-addr.arpa" IN { type master; file "192.168.10.zone (zone file name for reverse analysis)"; allow-update { none; }; };
3. Go to the location of the DNS zone configuration file /var/named and create a zone file for the forward domain. Here we directly copy the template file /var/namd.localhost and name it long.com.zone. You can see the name Start casually.
Modify (note that the IP address corresponding to the dns in line 9 here is the IP address of the server)
[root@localhost named]# vim long.com.zone
1 $TTL 1D
2 @ IN SOA @ root.long.com. (fully qualified domain name) (
3 3 a> ~ 10 ftp (the main name of the corresponding domain name) IN A A 192.168.10.3 (the corresponding IP set for ftp) 8 @ IN NS dns.long.com. (This is the authoritative dns domain name) 9 dns (the main name of the corresponding domain name) IN A 192.168. 10.1 (server’s IP) 6 1W ; minimum
4 ; ; retry
IN represents the network type; SAO represents the resource type; @ represents the current domain; NS and A are both resource record types, NS represents the authoritative server in the area, and A represents the IP address that determines the resolution of the domain name
A simple understanding of NS and A is that NS is followed by the host domain name, and A is followed by the IP address corresponding to the domain name.
The eighth row is fixed.
root.long.com. (fully qualified domain name) and dns.long.com. (here is the authoritative dns domain name)
Fully qualified domain name, the complete domain name of a computer or host on the Internet. Example: www.WordPress.com. The first part ("www") is thehostname. The second part ("WordPress site group") is the domain name. The last part ("com") is the TLD (Top-Level Domain).
Check the host name of this machine as localhost
4. Copy the template and create a reverse domain zone file
[root@localhost named]# vim 192.168.10.zone
1 $TTL 1D
2 @ IN SOA @ root.long.com. (
3 3 3> 4 1d; Refresh 5 1h; Retry 6 1W; Expire 7 3H); minimum 8 @ IN dns.long.com. 9 1 (This is the last digit of the server’s IP address) IN PTR dns.long.com. (corresponding domain name) < /span> 10 3 (ftp corresponds to the last digit of IP) IN PTR ftp.long.com. (corresponding domain name)
RTP is followed by the corresponding domain name and relative domain name; the 1 here not only represents 192.168.10.1, but also represents 1.10.168.192.in-addr.arpa, which indicates a zone name in the main configuration file.
Restart service
systemctl restart named
If the restart fails, the most likely cause is a typo. I missed a dot in "dns.long.com." and spent a long time looking for it.
5. Firewall permission and selinux shutdown
6. Test (self-test, the server tests itself)
Here I check the hostname again and it has changed
The test here found that it was unsuccessful. It was the local loopback address. Maybe someone had the wrong host name.
The host name has been changed
[root@localhost named]# vim long.com.zone
It has not been successful yet. Because we use the server as the client, we need to tell the client the IP address of the server. We modify /etc/resoly.conf
IP is the IP address of the local server, nameserver is used to specify the IP address of the domain name server, and multiple servers can be set;
Line 2 searches long.com, which means that when there are multiple servers, query them in order
Test again
server - displays the current server; ftp.long.com - displays the current server's IP, port, and IP corresponding to the FTP domain name;
192.168.10.3 displays the domain name of the ftp service.
success
Specific order: Global configuration file (/etc/named.conf) -> Location of the main configuration file (/etc/named.rfc1912.zones) -> Forward and reverse domain zone file locations (the location here Refers to: /var/named/forward|reverse file; as for why it is in /var/named, this is recorded globally)
Next time content