Jaume Sabater dixit: > A /etc/host.conf hi tens configurada la preferència alhora de consultar > noms de host: > > # cat /etc/host.conf > order hosts,bind > multi on > > Això sí: Les aplicacions "host" i "dig" consulten directament a DNS sense > passar per l'/etc/hosts. Les restants faran lo que diguis a /etc/host.conf.
I també podem configurar-ho al fitxer '/etc/nsswitch.conf', tot i que és menys habitual. La forma "estàndard" de resoldre noms en Linux és amb la funció 'gethostbyname()' però cada desenvolupador pot acabar fent el que li roti. Si vols veure si un determinat programa llegeix el '/etc/hosts' pots xafardejar-ho amb el 'strace'. # strace ping -c1 www.debian.org 2>&1" | grep ^open open("/etc/ld.so.cache", O_RDONLY) = 3 open("/lib/tls/i686/cmov/libresolv.so.2", O_RDONLY) = 3 open("/lib/tls/i686/cmov/libc.so.6", O_RDONLY) = 3 open("/etc/resolv.conf", O_RDONLY) = 4 open("/etc/resolv.conf", O_RDONLY) = 4 open("/etc/nsswitch.conf", O_RDONLY) = 4 open("/etc/ld.so.cache", O_RDONLY) = 4 open("/lib/tls/i686/cmov/libnss_files.so.2", O_RDONLY) = 4 open("/etc/host.conf", O_RDONLY) = 4 open("/etc/hosts", O_RDONLY) = 4 open("/etc/ld.so.cache", O_RDONLY) = 4 open("/lib/tls/i686/cmov/libnss_dns.so.2", O_RDONLY) = 4 open("/etc/hosts", O_RDONLY) = 4 -- ############################## ### Jordi Funollet ### http://www.terraquis.net