Configure DNS in Linux/etc/resolv. conf

Source: Internet
Author: User

File/etc/resolv. conf configures the DNS customer. It contains the domain name search sequence of the host and the address of the DNS server. Each line should contain one keyword and one or more parameters separated by spaces. The following is an example file:

Search mydom.edu.cn
Nameserver 210.34.0.14
Nameserver 210.34.0.2

Valid parameters and their meanings are as follows:

Nameserver indicates the IP address of the DNS server. There can be multiple rows of nameserver, each with an IP address. The following nameserver is queried only when the first nameserver does not respond.

Domain declares the host domain name. Many programs use it, such as the mail system. DNS queries are also required for hosts without domain names. If no domain name exists, the host name will be used and all content before the first vertex (.) will be deleted.

Multiple parameters of search indicate the domain name query order. When you want to query hosts without domain names, the hosts will be searched separately in the domain declared by search. Domain and search cannot coexist. If both exist, the domain and search will be used later.

Sortlist allows specific sorting of the obtained domain name results. Its parameters are network/mask pairs, which can be arranged in any order.

Red Hat does not provide the default/etc/resolv. conf file. Its content is dynamically created based on the options provided during installation.

Original article: Configure DNS customers in/etc/resolv. conf in Linux

In the/etc/resolv. conf configuration file: domain and search have the same effect.

The following description is clearer.

Domain linpro. No
Search linpro. No uio. No IFI. uio. No

Domain Function:

Had I typed Telnet math. uio. no. with the trailing dot, the resolver wowould have known it was an FQDN and wowould have looked up math. uio. no at once, without trying to append the specified domain first. not all applications are tolerant
Of the trailing dot, though, so it can't always be specified.

Search function:

When SSH gram is executed, the resolver first looks for gram. linpro. no, which does not exist; then gram. uio. no, which does not exist, either; and finally gram. ifI. uio. no, which will succeed because it does exist

Original article: Functions of the search and domain keywords in/etc/resolv. conf

The difference between domain and search and/etc/hosts lies in Chapter 19th DNS server of laruence's Linux private house dish (network setup)
Section: client settingsNote:
·/Etc/hosts: As mentioned above, this is the IP address file of the earliest hostname;

·/Etc/resolv. conf: This is the IP address setting file for connecting your client to the DNS host;

·/Etc/nsswitch. conf: the file must be set in/etc/hosts or/etc/resolv. conf before "decision!

Generally, the default hostname search in Linux comes from/etc/hosts. Why? You can check
/Etc/nsswitch. conf and find the hosts project:

[Root @ Linux ~] # Vi/etc/nsswitch. conf hosts: Files DNS
The files above is the use of/etc/hosts, and the last DNS is the use of/etc/resolv. conf DNS host IP search

Search! Therefore, you can use/etc/hosts to set the IP address's corresponding hosts! Of course, you can also switch him over, but always
/Etc/hosts is relatively simple, so it is better to put it in front!

Well, since we want to conduct DNS testing, we need to fill in our own IP address for/etc/resolv. conf content.
Hello! Therefore, you should write as follows:

[Root @ Linux ~] # Vi/etc/resolv. conf nameserver 192.168.1.254 nameserver 168.95.1.1 nameserver 139.175.10.20
Nameserver can be set to multiple, but since nameserver is traced one by one, you need to write the IP address of your DNS host at the top! Then you can start the test!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.