In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to configure DNS in the Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure DNS in the Linux system.
Running environment redhat 9.0, IP address 172.18.121.35, the domain name implemented is jb51.net
1. Install the software package required by DNS.
Check to see if bind software is installed and enter it in the terminal.
The code is as follows:
[root@localhost root] # rpm-qa | grep bind
Redhat-config-bind-1.9.0-13
Bind-9.2.1-16
Bind-utils-9.2.1-16
Ypbind-1.11-4
If the above text indicates that the installation is successful, if the above things are not inserted into the correct CD, install. Or install it by downloading the source code.
two。 Set the IP address and DNS
Enter netconfig in the terminal, enter enter, and enter IP,172.18.121.35 in the first line. The second line enters the subnet mask 255.255.255.0. The third line enters the gateway address: 172.18.121.1, and the last line enters DNS 172.18.121.35. And then make sure. Then enter the following command in the terminal
The code is as follows:
[root@localhost root] # service network reload
[root@localhost root] # service network restart
View IP information through ifconfig
3. Configure DNS
Configure DNS forward search with the following configuration file:
The code is as follows:
[root@localhost root] # cp / var/named/localhost.zone / var/named/jb51.net
First copy a configuration template file of the native DNS and modify it
The code is as follows:
[root@localhost root] # vi / var/named/jb51.net
$TTL 86400
$ORIGIN jb51.net.
@ 1D IN SOA jb51.net. Root.jb51.net. (
42; serial (d. Adams)
3H; refresh
15m; retry
1W; expiry
1D); minimum
1D IN NS @
1D IN MX 5 mail.jb51.net.
Www 1D IN A 172.18.121.35
Mail 1D IN A 172.18.121.35
Ftp 1D IN A 172.18.121.35
Pop3 IN CNAME mail.jb51.net.
Smtp IN CNAME mail.jb51.net.
To save and exit, press ESC first, then: wq.
Configure DNS forward search with the following configuration file:
The code is as follows:
[root@localhost root] # cp / var/named/named.local / var/named/172.18.121.rev
First copy a configuration template file of the native DNS and modify it
The code is as follows:
[root@localhost root] # vi / var/named/172.18.121.rev
$TTL 86400
@ IN SOA jb51.net. Root.jb51.net. (
1997022700; Serial
28800; Refresh
14400; Retry
3600000; Expire
86400); Minimum
IN NS jb51.net.
35 IN PTR www.yisu.com.
35 IN PTR mail.jb51.net.
35 IN PTR ftp.jb51.net.
Configure a master file of native DNS. After installation, it has a template. Modify it. The modified part is represented by thick lines.
The code is as follows:
[root@localhost root] # vi / etc/named.conf
/ / generated by named-bootconf.pl
Options {
Directory "/ var/named"
/ *
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
, /
/ / query-source address * port 53
}
/ /
/ / a caching only nameserver config
/ /
Controls {
Inet 127.0.0.1 allow {localhost;} keys {rndckey;}
}
Zone "." IN {
Type hint
File "named.ca"
}
Zone "localhost" IN {
Type master
File "localhost.zone"
Allow-update {none;}
}
Zone "0.0.127.in-addr.arpa" IN {
Type master
File "named.local"
Allow-update {none;}
}
Zone "jb51.net" IN {
Type master
File "jb51.net"
}
Zone "121.18.172.in-addr.arpa" IN {
Type master
File "172.18.121.rev"
}
Include "/ etc/rndc.key"
"/ etc/named.conf" [converted] 45L, 894C
Configure the order of the local domain name conversion program
The code is as follows:
[root@localhost root] # vi / etc/host.conf
Order bind,hosts
Multi off
Trim jb51.net
[root@localhost root] # vi / etc/resolv.conf
Nameserver 172.18.121.35
Nameserver 218.196.42.2
Namedsever 218.196.42.2
Domain jb51.net
Search www.yisu.com jb51.net
Option nochecknames rotate
4. Start the named service.
The code is as follows:
[root@localhost root] # service named start
5. Check whether the configuration is successful
The code is as follows:
[root@localhost root] # nslookup
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
The `- sil [ent] 'option to prevent this message from appearing.
> www.yisu.com
Server: 172.18.121.35
Address: 172.18.121.35#53
Name: www.yisu.com
Address: 172.18.121.35
> 172.18.121.35
Server: 172.18.121.35
Address: 172.18.121.35#53
35.121.18.172.in-addr.arpa name = ftp.jb51.net.
35.121.18.172.in-addr.arpa name = www.yisu.com.
35.121.18.172.in-addr.arpa name = mail.jb51.net.
>
Ctrl + D exit
If the above situation of the text indicates that the configuration has been successful.
6. In fact, in the process of configuration, you can check whether your configuration is correct by using named-g to see where your configuration file is wrong, and then modify it.
PS:DNS related profile description
. / etc/host.conf
When both DNS domain name resolution and / etc/hosts host table mechanism exist in the system, the host name interpretation order is determined by the / etc/host.conf. Example:
Order hosts,bind # name interpretation order
Multi on # allows hosts to have multiple IP addresses
Nospoof on # prohibits IP address spoofing
Order is a keyword, and the definition is interpreted using the native hosts host table first, and then search the bind name server (DNS) if it cannot be explained.
. / etc/resolv.conf
This file is the configuration file for DNS domain name resolution, and its format is very simple, with each line beginning with a keyword, followed by configuration parameters. There are four main keywords for resolv.conf, which are:
Nameserver # defines the IP address of the DNS server
Domain # define a local domain name
Search # defines a search list for domain names
Sortlist # sorts the returned domain names
An example of / etc/resolv.conf:
Domain ringkee.com
Search www.ringkee.com ringkee.com
Nameserver 202.96.128.86
Nameserver 202.96.128.166
The most important is the nameserver keyword, if you do not specify nameserver, you can not find the DNS server, other keywords are optional.
. / etc/hosts
Sets the IP address to correspond to the hostname table, which can be used for hostname interpretation. Such as:
# format: IP address hostname alias
The code is as follows:
127.0.0.1 localhost localhost.localdomain
192.168.1.1 debian debian
192.168.0.2 t02 t02.tiger
192.168.0.4 t04 t04.tiger
. / etc/name.conf
/ / generated by named-bootconf.pl
Options {
Directory "/ var/named"
/ *
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
, /
/ / query-source address * port 53
}
/ /
/ / a caching only nameserver config
/ /
Zone "." IN {
Type hint
File "named.ca"
}
Zone "0.0.127.in-addr.arpa" IN {
Type master
File "named.local"
Allow-update {none;}
}
This section is the original content of the named.conf file automatically generated by the system after you install the bind software. "directory" specifies that the directory where the dns record file is stored is / var/named. The text at the beginning of "/ /" is the description text, don't worry about it. The next two "zone" statements define the root of the dns server and the corresponding reverse query domain, and indicate that the root record file is "name.ca" and the root reverse query domain record file is "named.local". These two record files are also included in the system, so you don't have to change them. We don't have to change this part of the named.conf file.
But we can add a line under "diretory": forwarders {202.96.134.133;}. 202.96.134.133 is the address of the dns server of my telecom here, and the forwarders parameter indicates the server where the subsequent ip is located as an alternative dns server. That is, send a host that cannot be parsed by the native dns to this alternate dns server and let it parse.
The code is as follows:
Zone "jb51.net" IN {
Type master
File "named.jb51.net"
Allow-update {none;}
}
Zone "0.0.10.in-addr.arpa" IN {
Type master
File "named.jb51.net.rev"
Allow-update {none;}
}
This part is added by hand. The "jb51.net" domain and the corresponding reverse query domain are defined. "type master" indicates that the machine is the primary dns server (primary name server) for the "jb51.net" and "0.0.10.in-addr.arpa" domains. "named.jb51.net" and "named.jb51.net.rev" are the record files for the domain. These two files are also created by ourselves, so let's take a look at these two files.
. / var/named/naemd.***.com
Resource record file, located in the / var/named directory. This directory is defined in named.conf.
1. The contents of named.jb51.net file are as follows:
The code is as follows:
@ IN SOA netfinity.jb51.net. Root.netfinity.jb51.net. (
1997022700; Serial
28800; Refresh
14400; Retry
3600000; Expire
86400); Minimum
IN NS netfinity.jb51.net.
IN MX 10 netfinity.jb51.net.
Netfinity IN A 10.0.0.211
Lily IN A 10.0.0.139
Www IN CNAME netfinity.jb51.net.
Pop3 IN CNAME netfinity.jb51.net.
Smtp IN CNAME netfinity.jb51.net.
In this record file, there are five types of records. SOA is an acronym for Start Of Authority, followed by the hostname of your dns server, which is "netfinity.jb51.net." (notice the dot after the host name. Remember to add these dots to all the host names that appear in the record file. NS is the name server resource record, which indicates the name server in the domain. This is the dns server. MX is the mail exchanger resource record that indicates the mail server for this domain. You can write multiple MX records and specify multiple mail servers. The priority is determined by the number after the MX. The smaller the number, the higher the priority of the mail server. An is the host record, which corresponds to the host and ip address. CNAME is an alias record that gives a host a different name. For example, www.yisu.com and pop3.jb51.net all point to the same host netfinity.jb51.net.
. / var/named/naemd.***.com.rev
Contents of named.jb51.net.rev file:
The code is as follows:
@ IN SOA netfinity.jb51.net. Root.netfinity.jb51.net. (
1997022700; Serial
28800; Refresh
14400; Retry
3600000; Expire
86400); Minimum
IN NS netfinity.jb51.net.
211 IN PTR netfinity.jb51.net.
139 IN PTR lily.jb51.net.
This is the reverse domain record file of "jb51.net", which allows the dns server to provide the service of looking up the host name by the ip address. The PTR record corresponds the ip to the hostname. Since some programs require reverse queries, it is best not to omit the record files of the reverse query domain.
At this point, you have successfully configured a dns server that can parse the "jb51.net" domain.
At this point, I believe you have a deeper understanding of "how to configure DNS in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.