Frank Brodbeck <oakenshield@gmx.net> [2002-08-20 01:35:07 +0200]: > You don't have to do anything to get the modified resolv.conf > working. AFAIK it will be accessed everytime your machine can't > resolve a given address through /etc/hosts. > Please correct me if I'm wrong. First the search order is set by /etc/nsswitch.conf. Which would by default say 'hosts: files dns' for looking up hosts. The function that does the lookup is gethostbyname() which is part of the C library aka libc aka glibc. libc looks at /etc/nsswitch.conf and sees where it should look and failing finding it there where it should look next. When libc sees dns then it will look through /etc/resolv.conf and look for the 'search' and 'nameserver' directives. Using those it will look up the name. This is a very simplified version of life. Now the question, if you change /etc/resolv.conf does it take effect immediately or not? It depends. Any command that runs from the command line, does its thing, and exits will of course get the current contents of the file. But what about long running daemons? Sendmail, inetd, nfsd, ntp, etc. all run effectively forever. The behavior now depends upon the behavior of libc. I don't know the behavior of glibc. But I know that on hpux the libc there only reads the contents of /etc/resolv.conf on startup. It never reads it again. Therefore you need to kill and restart all of those long running daemons in order to get them to read the new contents of the file. With NFS it is frequently easier to reboot because NFS can be so troublesome. For this reason many of us prefer to always run a local named and have a nameserver entry 0.0.0.0 which points to the local machine. Then we can make changes to the local running named and the changes will take affect immediately for all programs that are running without needing to restart those long running programs. I have not looked at glibc. Does anyone know if glibc is smart enough to reread the /etc/resolv.conf file when it changes? Or perhaps it just reads it every time for every access. File buffer cache would keep it in memory and it would be pretty fast even with needing to read it every time. Or if cached it could look at file modification times. Bob
Attachment:
pgpQhVgTSy6Iz.pgp
Description: PGP signature