DNS domain name resolution configuration file/etc/resolv. conf

Source: Internet
Author: User
Tags website server nameserver

/Etc/resolv. conf

This file is a DNS domain name resolution configuration file. Its format is very simple. Each line starts with a keyword, followed by configuration parameters.
Resolv. conf has four keywords:
Nameserver # define the IP address of the DNS server
Domain # define a local domain name
Search # define the domain name search list
Sortlist # Sort the returned domain names

Detailed description:
Nameserver indicates the IP address of the DNS server. There can be multiple rows of nameserver, each with an IP address. When querying, it is performed in the order of nameserver in this file,
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.

  
An example of/etc/resolv. conf:
Domain centoscn.com
Search www.centocn.comwww.wgjlb.com
Nameserver 202.96.128.86
Nameserver 202.96.128.166

The most important is the nameserver keyword. If nameserver is not specified, the DNS server cannot be found. Other keywords are optional. Red Hat does not provide the default/etc/resolv. conf file. Its content is dynamically created based on the options provided during installation.

========================================================== ==================
How to configure the/etc/hosts file in Linux
-----------------------------------------------------
1. About/etc/host, host name and IP configuration file

Hosts-The static table lookup for host name (host name query static table)
The hosts file is a file in Linux system that is responsible for fast resolution of IP addresses and domain names. It is saved in the "/etc" directory in ASCII format and is named "hosts" (different linux versions, this configuration file may also be different. For example, Debian's corresponding file is/etc/hostname ). The hosts file contains the ing between the IP address and the host name, as well as the host name alias. Without a Domain Name Server, all network programs on the system query the file to resolve the IP address corresponding to a host name. Otherwise, you must use the DNS service program. You can map common domain names and IP addresses to the hosts file for quick and convenient access.

2. Configuration File
This file can be used to configure the Host ip address and the corresponding host name. The role of this file on a server-type linux system cannot be ignored. On a LAN or INTERNET, each host has an ip address, which separates each host and can communicate with each other based on the ip address. But the IP address is not easy to remember, so there is a domain name. In a LAN, each machine has a host name, which is used to distinguish hosts for mutual access.

The configuration file for the Linux host name is/etc/hosts. This file tells the host which domain names correspond to those ip addresses and which ip addresses correspond to those host names:
For example, this definition exists in the file.

Suppose 192.168.1.100 is a website server. Enter http: // linumu100 or http: // test100 on the webpage to open the web page 192.168.1.100.

Generally, this file records the local ip address and Host Name: </P>

3. configuration file format description

Generally, the content of/etc/hosts is similar to the following:
127.0.0.1 localhost. localdomain localhost
192.168.1.100 linmu100.com linmu100
192.168.1.120 ftpserver ftp120

Generally, each hosts file acts as a host. Each line consists of three parts, separated by spaces. The line starting with # is not explained by the system.
The hosts file format is as follows:
IP address host name/Domain Name

Part 1: network IP address;
Part 2: Host Name or domain name;
Part 3: Host Name alias;

Of course, each line can also be two parts, namely the Host IP address and host name; for example, 192.168.1.100 linmu100.

Here we can slightly explain the differences between the host name (hostname) and Domain name (Domain): The host name is usually used in the LAN. Through the hosts file, the host name is resolved to the corresponding ip address; the domain name is usually used on the internet, but if the local machine does not want to use domain name resolution on the internet, then you can change the hosts file and add your own domain name resolution.

4. What problems can the/hosts file help solve?

4.1 slow remote logon to linux Hosts

Sometimes the client wants to remotely log on to a linux host, but it will wait a long time after entering the password. This is because the linux host needs to resolve the ip address when returning information, if you add the IP address of the client to the hosts file of the linux host, then remote linux Login from the client will become very fast.

Note: Remote logon is not only about ssh, but also about mysql remote logon or file sharing query.

4.2 dual-host Interconnection

When the two hosts are connected by two machines, you must set your own ip address and add your own ip address and host name to the hosts file of the other host.

5. Host Name modification tool hostname

In fact, there is also a dedicated tool for modifying the host name, that is, the hostname
Hostname-show or set the system's host name

Show Host Name:
# Hostname
Linmu100
The host name of this host is linmu100, and the Host Name of the current host is displayed without parameters;

Set the host name temporarily:
# Hostname test100
# Hostname note: the host name is displayed.
Test100
Using the hostname tool to set the host name is only temporary. The host name will not exist the next time the system is restarted;

Display Host IP Address:
# Hostname-I
192.168.1.100

========================================================== ============================
Differences between hosts, host. conf, and resolv. conf in Linux

--------------------------------------------------------
Located in the/etc/directory.

1. hosts file.

Similar to the host file in Windows, it is a text file that stores the correspondence between IP addresses and domain names.

2. host. conf. # The parser queries the sequence configuration file.

Example: vi/etc/host. conf

Order hosts bind indicates that the local hosts file is queried first. If no result is found, try to find the BIND dns server.

3. resolv. conf

Configure the configuration file of the Linux System DNS Server:

Vi/etc/resolv. conf

Nameserver 192.168.0.1

Nameserver 202.99.96.68

Related Article

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.