Setting Up NTP for Time Sync

Discussion in 'Linux Networking' started by W. Watson, Jan 5, 2005.

  1. W. Watson

    W. Watson Guest

    I'm running two machines. One is an XP Pro box called solarblast, and the other is a
    RHL9 box called astropc2004. I see that ntp is running on the Linux box. I would like
    to be able to set its time via the accurate time solarblast keeps. How do I do that?
    I do not see a ntp man page. There is a /etc/ntp.conf. Do I need Samba?
    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 5, 2005
    1. Advertisements

  2. W. Watson

    ToYKillAS Guest
    ToYKillAS, Jan 5, 2005
    1. Advertisements

  3. W. Watson

    Snowbat Guest

    The server daemon ntpd is also a powerful client (driftfiles etc.) and
    does an excellent job. Another option is to set ntpdate to run as a cron
    Not for NTP.
    Snowbat, Jan 5, 2005
  4. W. Watson

    mgrd Guest

    You only need one line in /etc/ntp.conf :
    server solarblast

    Everything else within is optional.

    Make sure to SIGHUP the xntpd to reread /etc/ntp.conf
    mgrd, Jan 5, 2005
  5. W. Watson

    mgrd Guest

    In case Windows is serving NTP via udp/123, you just need one line in
    /etc/ntp.conf :
    server solarblast

    Don't forget to SIGHUP the xntpd to reread /etc/ntp.conf
    mgrd, Jan 5, 2005
  6. W. Watson

    prg Guest


    The links below are useful but "solution" evades me at the moment.

    Was just reading this:

    Before doing anything else, check that XP Pro _can_ act as a conformant
    -- ie., not extended by MS -- time server. If so, you will use ntp to
    connect Linux to XP Pro -- via TCP/IP, no samba should be needed. If
    not, you may be SOL :(

    Note: Just ran into a reminder -- XP uses MS's SNTP and not a
    conformant ntp. Has to do with Kerberos authentication as
    used/extended by MS, IIRC. Been a while since I've dealt with this.
    Something in my "archives"? Need to look.

    You may need to check out the new ntpv4 requirements:

    Then again, you can use the Linux ntpd to connect to the same time
    server and request joining a multi-cast group (can XP?) so that both XP
    and Linux process the same packets. ???

    Maintainging accurate RTC time on Linux is a bit problematic. Most
    (default) installations use hwclock which is really meant to work with
    a 24/7 box to calculate drift and adjust time. If you frequently (more
    than once a month) turn off your Linux box you probably need to look
    into Chrony:

    Rather than 86 this whole post I'll get back later after I've had a
    chance to look further -- I ought to in order to be prepared for the
    (inevitable) day that I must get XP and Linux time synching.
    Excuse the bandwidth usage.

    see ya'
    email above disabled
    prg, Jan 5, 2005
  7. W. Watson

    W. Watson Guest

    I have read the other posts to mine, and will look at some of things mentioned. Since
    I posted the original a few hours ago, a few things of interest have occurred.

    I discovered the need to put the "server" in my ntp.conf file, as
    mentioned by a few posters. The IP address is for the XP machine, solarblast. is for the Linux box, astropc2004. I then reset the clock and date
    through the RHL9 calendar icon on the panel of the desk top to be very far off the
    real time/date. I then used it again to fire up ntp, using a check box on the dialog,
    to get the info from the XP. A small "Waiting" dialog appeared for about 10 seconds,
    and then the calendar/date dialog disappeared. No change in date or time. I found
    this a bit odd, since if I fire up W2k on the Linux box, I can set its time from XP.

    After some more Googling, I found that the LocalNTP entry in XP's registry should be
    set to binary 1. Mine was binary 0. I then repeated the above on Linux, but still
    nothing. Perhaps I needed to boot XP. Haven't tried that yet. Setting the value to 1
    is still a little perplexing because W2k had no trouble with the sync.

    I see a few people suggested a SIGHUP. I'm sort of a rookie at this, but I think that
    means basically to restart NTP on Linux. I'll do that and reboot XP and report back.

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 5, 2005
  8. W. Watson

    W. Watson Guest

    Well, the XP boot and the ntp restart didn't change a thing. Linux didn't sync its
    time with XP.

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 5, 2005
  9. W. Watson

    Tauno Voipio Guest

    ntpd does not step the time if it is far off.

    Use ntpdate to coarse sync the Linux box before
    starting the ntp daemon.

    If you still have problems, run tcpdump for UDP
    port 123 to see if messages are exchanged. For
    decoded messages, use Ethereal instead of tcpdump.
    Tauno Voipio, Jan 5, 2005
  10. W. Watson

    Bill Unruh Guest

    Does your XP box run an NTP timeserver?

    What makes you think your XP box is accurate?

    Note that you may also be confused about ntp. It does NOT change the clock
    to the correct time. It changes the rate of the clock so that it will
    eventually (depending on how far off it is) get to the right time.
    Bill Unruh, Jan 6, 2005
  11. W. Watson

    W. Watson Guest

    Me, confused? :) Here's the plan. I want my linux box, astropc, to get its time from
    the xp box, solarblast, my workhorse. Every few hours or while I'm on the network via
    an accurate time off the internet. I pretty sure there's some way to schedule this on
    xp; however, the big concern at the moment is can I do the above.

    I know that I can get an accurate time from the internet by using the calendar icon
    on the panel at the bottom of the desk top. I know that if instead of bringing up
    astropc on w2k instead of linux, I can send a net time to solarblast to set the
    astropc clock. When astropc is doing its sworn duty, to run a meteor camera 24/7,
    then I want astropc to update its clock every six hours or so from solarblast. A
    chron job should do that. I've been told that I need ntp running on linux. It is. I
    think I need to set the LocalNTP registry value to binary 1. I've done that but it
    didn't help. Further, I know when I ask the calendar/time icon on linux to get the
    time from (solarblast), it tries, but fails--even if I set the clock on
    astropc to within 30 seconds of the realtime. Do I know if XP uses NTP? No, but I'm
    assuming it does. (Har, har. Perhaps the joke is on me?)

    Short of that, yes, I'm confused. :)

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 6, 2005
  12. W. Watson

    W. Watson Guest

    There's no ntpupdate on my machine. I'm using RHL9. It's probably on a package I
    didn't install. Ethereal? Didn't try it. I'll look later. Probably not there.

    There is tcpdump. From some distant memory, I think one runs such a program in the
    background. I just tried tcpdump& and asked the calendar/time icon program to get the
    time from (solarblast, xp). It gave me some messages with -6 (DF). Sounds
    bad to me. The correct time was not established on linux. Is the default to listen to
    port 123. If not, or in any case, how do I run tcpdump?

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 6, 2005
  13. W. Watson

    Bill Unruh Guest

    A) You might consider having your Linux box be the one that gets its time
    off the internet and sync the windows box to it. In particular, run chrony
    on the Linux box, and every time you go onto the net, set ( via a script
    which runs chronyc) the remote system to be online and when you go off the
    net, set it offline. Chrony will use those times it was on to determine
    both the offset and the rate error of your system clock.

    B) Put an ntp server onto your XP server. Eg see
    (I have not used it or done it. I do not use windows, but this was the
    second entry when I googled for ntp and windows.)
    Then point your Linux server at it.
    Bill Unruh, Jan 6, 2005
  14. if your XP is real ntp time server
    to use automatically ntpdate on boot you
    need to create a file called
    cointaining only the name or ip address of your ntp server

    with this file when you start ntp on linux an ntpdate is executed
    from /etc/init.d/ntpd

    # Adjust time to make life easy for ntpd
    if [ -f /etc/ntp/step-tickers ]; then
    gprintf "Syncing time for ntpd. "
    /usr/sbin/ntpdate -s -b -p 8 -u `cat /etc/ntp/step-tickers`
    Philippe WEILL, Jan 6, 2005
  15. W. Watson

    Tauno Voipio Guest

    The program is ntpdate, not ntpupdate. It should come
    together with the ntp package.
    Tauno Voipio, Jan 6, 2005
  16. W. Watson

    prg Guest

    Excuse me for replying out to the top, but was afraid it might get
    "lost" in all the posts. This is a _long_ one ;-)

    Sorry for the delay getting back -- been _really_ hectic around here.

    Note: from another of your posts:
    "When astropc is doing its sworn duty, to run a meteor camera 24/7,
    then I want astropc to update its clock every six hours or so from

    If Linux will be up 24/7 _and_ is running a meteor camera (so accurate
    time is needed) you will be better off having the Linux box (sorry,
    your pet names are meaningless to me) should be fetching its time synch
    directly from (preferably) 3 or 4 stratum 2 time servers. XP's
    algorithms are less than stellar, much less state-of-the art. Time
    precision and clock frequency discipline in the nanoseconds range is
    _possible_ (but not necessary in your case) and 1-2 ms variance is
    "normal". The software is there and ready to run -- why let XP rob it
    (and you) of this capability.

    Have gone through all the MS/XP docs I could find that seemed promising
    and weeded out 75% of them. Nothing like a change in code and redesign
    of registry entries to confuse things.

    Beware, the current (below) docs all assume XP SP2 is installed and I
    would not even try to figure out what went/is going on pre-SP2.

    Your case: XP Pro defaults to booting up as a domain member. No
    domain, it must be configured to synch to an outside time source (as a
    client). You've accomplished that. But double check and write down
    your current setup for reference ;) You're probably working with
    poorly designed MS defaults -- even they admit as much. See the links
    about configuring XP as a "server" below -- the first batch.

    Note: quirk re: terminolgy. NTP considers _all_ particpants as
    "servers" -- clients are just servers that have no one asking them for
    the time. Probably because NTP uses UDP port 123 for listening _and_
    responding. Most services (all that you'ld likely install) use 2 or
    more ports to carry on a conversation.

    Windows quirk: you have to let it know (after a fashion) that it
    _ought_ to respond to requests for the time. Thus the several links
    re: setting up XP as a Time Server.

    Windows quirk: as an NTP client, the firewall automatically allows NTP
    traffic through port# 123 -- courtesy of the fact that the client
    always _initiates_ the traffic exchange so all replies are _related_ to
    that request (similar to Linux connection tracking). As a server
    (opinions found varied) you must manually set up the firewall to allow
    UPD traffic through port# 123. See firewall links below (could not
    find any eg., specicfic to NTP, but you know it's NTP protocol on UDP
    port# 123 on the nic connecting to Linux box).

    The easiest way for the unfamiliar to set up the ntpd in RH Linux is to
    open an X terminal/console and type:
    [enter root password]
    In the gui tool that launches, scroll down the upper list and select
    ntpd, click Start, save your changes to have it start at boot. This
    assumes you will be running Linux in graphical mode (aka runlevel 5).
    It is wise to go ahead and Edit | Runlevel 3 and select ntpd there as
    well (don't click start).

    RH9 probably came with a firewall configured -- Lokkit -- and unless
    you've substituted your own iptables script you should confirm that
    /etc/init.d/ntpd has this code:
    start() {
    if [ -n "$FWACTIVE" -a "$FIREWALL_MODS" != "no" ]; then
    echo -n $"$prog: Opening firewall for port 123"
    iptables -I RH-Lokkit-0-50-INPUT -m udp -p udp -s 0/0 \
    --sport 123 -d 0/0 --dport 123 -j ACCEPT\
    && success || failure
    if [ -s "$ntpstep" ]; then
    tickers=`/bin/sed -e 's/\#.*$//g' $ntpstep`
    echo -n $"$prog: Synchronizing with time server: "
    /usr/sbin/ntpdate -s -b -p 8 $tickers
    [ $RETVAL -eq 0 ] && success || failure
    [ ! $RETVAL -eq 0 ] && return $RETVAL
    # -g can replace the grep for time servers
    # as it permits ntpd to violate its 1000s limit once.
    # Start daemons.
    echo -n $"Starting $prog: "
    daemon ntpd $OPTIONS
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ntpd
    return $RETVAL

    It will run whenever you boot with ntpd configured to start at boot.
    (It's a Linux way/trick) Note that it opens a hole in the firewall for
    ntpd _and_ invokes ntpdate for you on condition that time offset is <
    1000s (16+ minutes) and that you have placed a time server (XP) in the
    /etc/ntp/step-tickers file. Obviously XP must be up and ready to serve
    time clients.

    An alternative approach can be found in this article:
    Working With Time
    Middle third is a good, diy howto. Even if you configure ntpd using
    steps above, the article's step 3 (create entries in the
    /etc/ntp/step-tickers file) is useful.

    Used your own/borrowed FW script? You're on your own.

    Windows quirk??? : XP ntpd is version 3. Linux will say it's version
    4. XP may reject v4 packets? I ran across (then lost) a post/link
    that indicated that this may be a problem. That is, XP is backward
    compatible but not forward. You may need to force Linux to claim
    version 3 with version tag in ntp.conf. See Linux docs (confopt.htm)

    When initially synching, it is best to have the _clocks_ as close in
    time together as you can eyeball them -- < 1 minute for sure, < 15 secs
    if possible. The NTP code adjusts _time_ by throttling the frequency
    of the clock souce so that drift and network conditions are
    _statistically_ accounted for. This is why it can take (literally) all
    day to achieve "synch". See link below on XP's take on large offsets.

    Once you have basic synching, you will want to go back and apply some
    of the registry changes that control _how_ XP behaves as a client and a
    server. Wait till you have achieved the basics first.

    You probably won't have to change anything in Linux ntp.conf except
    pointing it at XP, perhaps apply the -version 3 tag.

    Windows Time Service << Discussion of Win ntp service
    Published: August 6, 2004

    How To Synchronize the Time with the Windows Time Service in Windows XP
    Last Review:July 14, 2004;en-us;307897&sd=tech

    How to configure an authoritative time server in Windows XP
    [see "stand alone" -- like you];en-us;314054

    Windows Time Service Tools and Settings

    Configuring the Windows Time service against a large time offset;en-us;884776
    [Related to, but not specific to, your experience]

    FIX: Windows Time Service ignores the local polling interval values in
    Windows Server 2003 and Windows XP
    [This is a SP2 fix]

    HOW TO: Turn On Debug Logging in the Windows Time Service
    Last Review:February 3, 2004;en-us;816043

    This non-MS page may be useful/handy:
    Windows XP Tip of the Day
    Tip #553: Windows Time Service Settings

    XP commandline tools:

    Troubleshooting Windows Firewall in Windows XP SP 2
    Published: September 22,

    Manually Configuring Windows Firewall in Windows XP SP 2
    Updated: December 17, 2004

    Linux Time/Clock

    Many of the above links (and others) from these google searches (and
    many others searches with too much chaff):

    This one adds some more:
    "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\"\Services\W32Time\Config\ "&btnG=Search

    Completes my "best" (ie.,fruitful) efforts:
    XP W32TM command W32TM command&ie=UTF-8&oe=UTF-8

    Use this uri in your browser to access your ntp docs according to my
    quick check ($rpm -qpl ntp-4.1.2-0.rc1.2.i386.rpm | more) of the rpm
    that came with RH9.
    How NTP Operates
    Frequency Discipline

    Configuring Clients and Servers
    Quick links at page bottom

    In no particular order -- just the one I think appropriate;)

    The whole thing

    Configuration Commands

    If you need to sniff the packets on the wire (ie., XP'x debugging not
    enough) I highly recommend you use ethereal (already on your Linux) on
    the XP machine. It's a snap to install/use. It's on my Win fix-it
    tools cd. Find it here:

    You will need to install the WinPcap library:

    as well as ethereal itself:
    email above disabled
    prg, Jan 7, 2005
  17. W. Watson

    W. Watson Guest

    I lost typing brain cells upon returning from my 100' foot travel yesterday to the
    other building to type in ntpdate. When I got back here, my hand typed in ntpupdate.
    I just checked again, and found that ntpdate is in /usr/sbin and apparently not on
    the 'default' path. I executed it from there and got a message something like "does
    not exist on any server".

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 7, 2005
  18. W. Watson

    Tauno Voipio Guest

    Did you write:


    where is a nearby NTP server (mine is You have to tell the server to ntpdate.

    man ntpdate
    Tauno Voipio, Jan 7, 2005
  19. W. Watson

    W. Watson Guest

    I just tried yours and got "no severs can be used. exiting." How do I find one for
    the west coast of the U.S.? California, for example. I have no man page for ntp or

    Wayne T. Watson (Watson Adventures, Prop., Nevada City, CA)
    (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time)
    Obz Site: 39° 15' 7" N, 121° 2' 32" W, 2700 feet

    Web Page: <>
    W. Watson, Jan 7, 2005
  20. W. Watson

    prg Guest

    OP probably does not have any man pages for ntp on RH9 as the docs were
    distributed as html files in:

    RH9 came with a firewall preconfigured -- Lokkit -- and unless you've
    substituted your own script (it checks for Lokkit) /etc/init.d/ntpd
    will do two things:
    1) open a FW hole for ntp
    2) automatically call ntpdate using the servers located in

    1) is not that difficult to add to any script and 2) could be easily
    adapted to work in just about any script. I think it's especially
    useful/convenient for folks that frequently shut down their Linux box.

    You can google:
    linux + "/etc/ntp/step-tickers"
    about 1,420 English pages for linux + "/etc/ntp/step-tickers"
    or click here: + "/etc/ntp/step-tickers"&ie=UTF-8&oe=UTF-8
    email above disabled
    prg, Jan 7, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.