Home » Questions » Computers [ Ask a new question ]

Can the order in which a DNS entry is looked up be changed?

Can the order in which a DNS entry is looked up be changed?

Can the order in which an entry is looked up at the DNS or the hosts (/etc/hosts) be specified on Linux?

Asked by: Guest | Views: 243
Total answers/comments: 1
Guest [Entry]

"Generally this is done with the /etc/resolv.conf and /etc/nsswitch.conf files. For determining the order, look at the ""hosts"" line of nsswitch.conf.

nsswitch.conf is where you configure the name service switching. This is a pretty standard one from a Debian Lenny system:

# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc ""Name Service Switch""' for information about this file.

# ...

# HERE vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
networks: files

protocols: db files
services: db files
ethers: db files
rpc: db files

resolv.conf lists your DNS servers and which domain names should be appended to the hostname by default. It's likely generated automagically by your DHCP client.

search lan
nameserver x.x.x.x"