/etc/hosts file setting for no dns lookup

8,645

Solution 1

Can you explain me what I need to add in my hosts file for no dns look up

That is the wrong question to ask. The hosts file does not control whether or not DNS lookups are performed; it just provides a way to obtain IP addresses w/o DNS.

To control lookup behaviour, you need to modify /etc/nsswitch.conf (at least on Linux).

Solution 2

The file you need is host.conf, this configures the DNS resolver for the system. To disable external DNS lookups and to use only the hosts file use:

order hosts

In addition, depending on the distribution, you may need to edit nsswitch.conf as well.

Share:
8,645

Related videos on Youtube

vinayrks
Author by

vinayrks

Updated on September 17, 2022

Comments

  • vinayrks
    vinayrks over 1 year

    Can you explain me what I need to add in my hosts file for no dns look up

    • sleske
      sleske about 14 years
      Please specify your OS. This question is highly OS-specific.