"The Linux Gazette...making Linux just a little more fun!"

How 'ntpdate' finds IP addresses?

From Pete O'Donnell on Tue, 23 Feb 1999

In an article on setting system clocks to atomic clock time, you referred to
the following line:

/usr/sbin/ntpdate -s ntp.ucsd.edu ns.scruz.net ntp1.cs.wisc.edu

Do these 3 servers have entries in the /etc/ntp.conf file or
is there some sort of host file set up on your machine? How does the
xntpd daemon find the corresponding IPs. Let me know.
Thanks answer guy.

-Pete O'Donnell
LiveNetworking

The /etc/ntp.conf file is used by xntpd --- not be
by the ntpdate command. The 'ntpdate' command finds
IP addresses that correspond to these host names in
the same way that any other Unix utility or application
does. Almost all Unix utilities that do any sort of
network operation are linked against a set of "resolver"
libraries. The "resolver" libraries differ a bit
among systems --- but most of them look in the /etc/hosts
file, for a hostname match (grabbing an IP address from
there if they find one) and then read the /etc/resolv.conf
file for a list of nameservers (DNS). In other cases
your resolver libraries might make requests (RPCs?) of
one or more NIS (YP) servers in your NIS domain, and
newer configurations --- using glibc's modular NSS (name
services switching) as controlled by /etc/nsswitch.conf
might query LDAP, NDS (Novell) or other backend
directory/name services systems for their mapping.

(Under libc5 there was a /etc/hosts.conf that gave more
limited and less extensible control over which name services
were/are queried and in which order).

Read the man pages for those files (/etc/hosts,
/etc/nsswitch.conf, /etc/hosts.conf and
/etc/resolv.conf) for some details. You can also look at
http://www.openldap.org for some cool info about future
use/deployment of LDAP.