Name Resolver Configuration (resolv.conf) in Linux

Name Resolver


The name resolver is used to convert a human friendly name (hostname) to machine friendly name i.e. (IP address). It is use to configure client side access to the Internet Domain Name System (DNS). This file defines which name servers to use.


Fully Qualified Domain Name


A fully qualified domain name (FQDN) is the complete domain name for a specific computer or host on the Internet. The FQDN consists of two parts: the hostname and the domain name.
The following are examples of FQDNs:
www.pagelinux.com
mail.pagelinux.com

Here .com is the top-level domain (TLD). This is similar to the root directory, from which all other directories originate.
www.pagelinux.com is the FQDN of the web server. Here www is the hostname and pagelinux.com is domain name.


/etc/resolv.conf


The /etc/resolv.conf is the main resolver configuration file. Its format is human readable and contains a list of keywords with values that provide various types of resolver information. It is a text file that has one keyword per line.

File name is /etc/resolv.conf and not /etc/resolve.conf.


The most used keywords are:

domain: This keyword specifies the local domain name.

search: This keyword specifies a list of alternate domain names to search for a hostname.

name server: This specifies an IP address of your own nameserver or to ISP's name server toquery when resolving names



An example of /etc/resolv.conf file is shown below:

search example.com

nameserver 147.11.1.11

nameserver 147.11.100.30

   
/etc/resolv.conf file in Linux


/etc/host.conf


Linux uses a resolver library to obtain the IP address corresponding to a host name. The /etc/host.conf file specifies how names are resolved. The entries in the etc/host.conf file tell the resolver library what services to use, and in what order, to resolve names.

This configuration tells the name resolver to check the /etc/hosts file before attempting to query a name server. It also tells the resolver to return all valid addresses for a host found in the /etc/hosts file (instead of just the first address).

An example of /etc/host.conf file is shown below:

# /etc/host.conf

# Lookup names via DNS first then fall back to /etc/hosts.

order bind,hosts

# We have machines with multiple IP addresses.

multi on

# Check for IP address spoofing.

nospoof on



The order option indicates the order of services. The sample entry specifies that the resolver library should first consult the name server to resolve a name and then check the /etc/hosts file.

The multi option determines whether a host in the /etc/hosts file can have multiple IP addresses i.e.multiple interface ethN. Hosts that have more than one IP address are said to be multiomed, because the presence of multiple IP addresses implies that host has several network interfaces.

The nospoof option indicates to take care of not permitting spoofing on this machine.

IP spoofing refers to connection hijacking through a fake Internet Protocol (IP) address. IP spoofing is the action of masking a computer IP address so that it looks like it is authentic. During this masking process, the fake IP address sends what appears to be a malevolent message coupled with an IP address that appears to be authentic and trusted.



/etc/hosts


The /etc/hosts file is used by your system to resolve fqdn to IP addresses. The /etc/hosts is file where you put the name and IP address of local hosts. If you place a host in this file, then you do not need to query the domain name server to get its IP Address. 

A default /etc/hosts file contains the entry for the loopback interface,



An example of /etc/host file is shown below:

# /etc/hosts

127.0.0.1 localhost.localdomain localhost


The format of the hosts file is: SOURCE DOMAIN HOSTNAMES.

You may specify more than one host name per line (as demonstrated by the first entry), which is a standard entry for the loopback interface.



network-interface-configuration

No comments: