DNS Resolution with resolv.conf

How do I edit the “/etc/resolv.conf” file?

Use text editor such as vi or gedit from Linux desktop:

# vi /etc/resolv.conf

There are three main configuration directives in /etc/resolv.conf:

nameserver # DNS server IP
domain # Domain Name of local host
search # Which Domain to search

The “nameserver” directive

The nameserver directive points out to the IP address of a Name Server.

nameserver <IP address>

It can be your own Name Server, some public Name Server or the Name Server of your’s ISP.

Note: Up to 3 name servers may be listed.

Example:

nameserver 192.168.0.100
nameserver 8.8.8.8
nameserver 8.8.4.4

The “domain” directive

Local domain name.

domain <local domain name>

Example:

domain domain.com
nameserver 192.168.0.100
nameserver 8.8.4.4

How the “domain” directive in the “resolv.conf” file works?

You can use domain directive for resolving short host-names – e.g. test.
So if you have the following in your /etc/resolv.conf:

domain example.com

Then your computer will try to resolve test.example.com.

The “search” directive

Search list for hostname lookup. The search list is normally determined from the local domain name but it can be set to a list of domains.

search <search list>

Example:

search example.com company.net
nameserver 192.168.0.100
nameserver 8.8.8.8

How the “search” directive in the “resolv.conf” file works?

You need to use search directive for resolving short host-names – e.g. test.
So if you have the following in your /etc/resolv.conf:

search example.com company.net

Then your computer will try to resolve test.example.com followed by test.company.net. It will return the first query that was successful.

  • 2 Bu dökümanı faydalı bulan kullanıcılar:
Bu cevap yeterince yardımcı oldu mu?

İlgili diğer dökümanlar

How To: Back Up MySQL Databases From The Command Line

While automated backups are important, sometimes you just want to take a quick and dirty snapshot...

How To Install MariaDB on CentOS 6

MariaDB is a drop-in replacement for MySQL. It is easy to install, offers many speed and...

How to Display (List) All Jobs in Cron / Crontab

View Root’s Cron Jobs crontab -l  View a User’s Cron Jobs crontab -u username -l Example with...

How To: Automate Server Scripts With Cron

Servers can automatically perform tasks that you would otherwise have to perform yourself, such...

How to find sending spam emails and enable mail header in php.ini

- In Linux servers if there are a lot of emails in the queue "over 100" emails. you can check if...