Wednesday, January 24, 2018

linux: Turn off DNS to only use /etc/hosts file for host look up

On linux, each line of the /etc/hosts file contains an IP address and the domain names for this IP address separated by a space. For example, the line below have the domain names localhost, myserver, and deserver mapped to IP address 127.0.0.1.

      127.0.0.1      localhost myserver deserver

It provides an alternative way to get IP address from a domain name without DNS (Domain Name Service) look up.

To turn off DNS look up and only use the /etc/hosts file on  linux: Login as root user.

1. Modify the /etc/host.conf file.

This Resolver Configuration file specifies the order of the domain name to IP address look up.  For example, the line below tells that the host look up program should look at the /etc/hosts file first; if it does not find the result there, it should then use the DNS to get the IP address; if the result is still not found, it will use the old NIS (Network Information System).

       order hosts,bind,nis

 To only use the /etc/hosts file for host look up, modify the line above to make it look like this.

      order hosts

2. Modify the /etc/nsswitch.conf file. 

The Name Service Switch (NSS) configuration file, /etc/nsswitch.conf, is used to determine the sources from which to obtain name-service information in a range of categories, and in what order.

To only use the /etc/hosts file for host look up, find the line starts with "hosts: " and make it look like below.

      hosts:  files

--------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.


No comments:

Post a Comment