Setting Up NTP for Time Sync

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

  1. W. Watson

    Bill Unruh Guest

    Well, you do have to tell it which server to use.
    man ntpdate should give you information.
     
    Bill Unruh, Jan 7, 2005
    #21
    1. Advertisements

  2. W. Watson

    W. Watson Guest

    prg wrote:

    ....
    Found a suitable man page on the web.
    Tried the Finish site mentioned, and got the same message. Noted in another message
    just posted minutes ago.
    I've made no changes to the script file that I know of. What is it called?

    How do I tell if Lokkit is running? If it is, then I think you are suggesting that I
    add a script that will open the FW for ntp. Someone mentioned step-tickers earlier
    with an example. I need to review what that's about.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 7, 2005
    #22
    1. Advertisements

  3. W. Watson

    W. Watson Guest

    Yes, skipping ahead might be good on these long threads.

    That's an impressive amount of research. I'll need to print this and take a look at
    it all. Somehow I feel I'm a whisper away from the solution, and that may be through
    ntpdate.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 7, 2005
    #23
  4. W. Watson

    W. Watson Guest

    No modem on it. Don't plan to put one on it. I think the ntpdate is worthwhile
    exploring at this time. Something is amiss here, and pursuing that approach may find
    some hidden difficulty.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 7, 2005
    #24
  5. I have a cron job that runs "ntpdate -b us.pool.ntp.org" every
    few minutes.

    Take a look at <http://pool.ntp.org/> for more information.
     
    Floyd L. Davidson, Jan 7, 2005
    #25
  6. W. Watson

    Bill Unruh Guest


    a) can your Linux machine get onto the net at all. If it cannot, then all
    of this is irrelevant. YOu would have to get your windows machine to act as
    an ntp server for you. If your Linux machine can get onto the net somehow,
    then other options open up. But I got the feeling it could not.
    b) If not, then you must set up your windows machine as an ntp server. This
    means getting the ntp server software and installing it. Then y ou would
    point your linux machines ntpdate at the windows machine to get the time--
    ie
    ntpdate 111.222.333.444
    where that address is the ip address your linux machine known your windows
    machine as.
     
    Bill Unruh, Jan 7, 2005
    #26
  7. W. Watson

    prg Guest

    Your web browser will give you ready access to all the docs via
    the link ;-)
    called?

    No changes is good in this case ;-)

    Lokkit is just RH's "name" for their FW script. In /etc/rc.d/init.d
    you will find all the startup/boot init scripts. The FW script is
    called iptables after the command "iptables" that manipulates the
    packet filter facilities included with Linux.

    The /etc/init.d/ntpd script is the one run when ntpd is started.
    $ su - << note dash
    [enter root password]
    # service iptables status

    If it is running you'll see the tables printed to screen. If it is not
    running you'll get the message "Firewall is stopped." If by some
    accident you don't have any tables you'll see "Firewall is not
    configured. "
    Actually, the script is already in place and ready to go. The
    /etc/ntp/step-tickers config file is initailly blank -- as in 0 bytes.
    It holds the name of a single time server to contact _before_ ntpd
    starts in order to set your time very quickly from an accurate source.
    Allows your ntpd to synch much more rapidly.

    To tell the truth, a more normal day has restored a few brain cells and
    made me realize that we are making this more difficult for you than
    need be. RH has scripts that will set up ntpd and initialize your
    configuration with two selections in a gui -- then poof ;-)
    $ su -
    [enter root password]
    # redhat-config-date

    In the gui that pops up, check "Enable Network Time Protocol" and in
    the dropdown list select "clock.redhat.com" if you have access to the
    internet with the Linux box. If not you can try the IP address of your
    XP box. Click OK and RH will arrange the rest. You should get a
    message telling you to wait while it gets the date/time from the time
    server.

    Nice thing is that it will set up these files with useful values that
    will act as a guide if you need/decide to edit by hand:
    /etc/ntpd.conf
    /etc/ntp/step-tickers
    /etc/ntp/ntpservers
    /etc/ntp/drift

    [root]# service ntpd status
    ntpd (pid 3216) is running...

    And as a part of the startup process it will run the /etc/init.d/ntpd
    script and will modify your iptables rules (Lokkit) to open the
    firewall to ntp traffic. No muss, no fuss. Broke down my old system
    here and just used it.

    [root]# service iptables status
    Chain RH-Lokkit-0-50-INPUT (1 references)
    target prot opt source destination
    ACCEPT udp -- anywhere anywhere udp spt:ntp dpt:ntp
    yada yada yada ...

    When you get in the habit of using commandline tools and editing files
    by hand so much it's easy to forget that some of the gui tools really
    do work pretty well for the inexperienced. In fact, I feel like a
    dufus for not thinking about it and checking earlier.

    This should set up your Linux box for ntp. Now your XP box...
    hth,
    prg
    email above disabled
     
    prg, Jan 8, 2005
    #27
  8. W. Watson

    W. Watson Guest

    Let's hope I get this typed and sent before our next power outage. We've had two in
    the last hour.

    I can dial in and connect to the internet with Mozilla.

    Shouldn't ntpdate x with x=IP address of my local (California) ntp server? Ah,
    thunder. BTW, where do I find a site in California (Northern) that I can use.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #28
  9. W. Watson

    Bill Unruh Guest

    I thought you said that you could not or did not want to connect via the
    Linux machine. I thought that your topology was something like

    _______ ____________ ____________
    |Linux|____________| Windows |______________ Modem |_______________|Net
    | | | | | | |
    ------ ----------- --------

    Ie your linux system was connected to your win system which occasionally
    connected to the net via some modem connection. YOu felt that you could
    sync your win machine to the atomic clocks on the net and wanted to know
    how to then sync your Linux machine to your Win machine.

    NOw you seem to say that you can connect your Linux machine directly to
    the net via a modem. If this is the case, then run chrony on your Linux
    machine, and when you ppp connect to the net place a little script which
    puts chrony online when ppp comes up and offline when it comes down.

    Eg
    #!/bin/bash
    chronyc<<EOF
    password password
    online
    exit
    EOF

    for running in ip-up
    and
    #!/bin/bash
    chronyc<<EOF
    password password
    offline
    exit
    EOF

    in ip-down
    This will allow chrony not only to set your clock but also to determine
    its rate error and correct for that as well. (eg if your computer system
    clock runs slow by 5 sec per day, then if you use ntpdate to correct the
    clock every day, it will oscillate to being slow by 5 sec and then jump
    to correct only to loose its 5 sec. With chrony, it will correct for the
    5 sec per day rate error, and it will never be more than a few
    milliseconds out per day)

    Alternatively if you windows machine is connected to an atomic clock
    (gps or whatever) then set it up as an ntp server, and have Linux use it
    as the server.

    Or connect the atomic clock to the Linux machine, run ntpd and have it
    use that atomic clock and have the win machine get its time from the
    Linux machine.
     
    Bill Unruh, Jan 8, 2005
    #29
  10. W. Watson

    W. Watson Guest

    OK, here's the inside scoop. What I'm doing is a test bed for the real magilla. It is
    true that on the test bed machine, astropc, I have a modem, but on the actual
    machine, meteorpc, I plan to implement the final result, there will be no modem. When
    you asked if I can get out to the internet, I thought maybe you had in mind some way
    to test the authenticity of whether from linux I can indeed synch to the outside
    world. I belive that is, in fact, a reasonable thing to try. Since I have no idea
    where an ntp server is on the west coast, I guess I'll just use the Finnish one given
    by another poster.

    At this point, what I'm doing is a proving ground for the real machine, meteorpc. I
    do not want to disturb it while I'm trying to figure how I can get time for its
    application accurately. At this point, all I know is that ntp gets me a independent
    time, which supposedly is very accurate. I assume atomic time. I'm also assuming it
    will some how adjust for any delay in getting it to me. If not then, I need to get to
    something that will. I've read that such connections can be made somehow via the
    internet. I really don't know.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #30
  11. W. Watson

    prg Guest

    Would it be at all possible that you use meaningful designations for
    your machines when posting -- Doug, Sammy, Dorothy, and Betty or
    astropc or solorblast or moonrocket may be quite useful to you but they
    add obscurity for us. Pretty please. I'm asking nicely :)
    And what _sort_ of OS is metropc running -- need data. Can we guess
    that it will run Linux?
    Synching to the outside world -- directly or indirectly -- is the only
    way to acquire accurate time. It would confirm that your RH9 box is
    properly set up and it will set the pc's clock.
    You want a time server as close as possible so it will introduce as few
    variables into drift as possible. Try this to get a list of time
    servers:

    http://ntp.isc.org/bin/view/Servers/StratumTwoTimeServers

    I found these stratum2 (open access) time servers in CA:

    ntp1.mainecoon.com
    ntp1.sf-bay.org
    ntp2.mainecoon.com
    ntp2.sf-bay.org
    ntp.ucsd.edu
    reloj.kjsl.com
    time.berkeley.netdot.net
    time.five-ten-sg.com

    Go to the site for details. You probably need to send them an email to
    let them know you will be using their server (it's considered polite).
    To start with, your Linux box will offer a redhat time server in the
    gui.
    As accurate as you will need -- on the order of 2-5 ms. And it's nice
    that you have a testing platform -- be sure to take notes ;-)
    Please take the time to read the docs, try to understand them, then
    come back for answers which you will need to clarify the muddy parts.
    You don't have to learn it all -- just read the basics in the doc
    sections pointed out in my "long" post. Several of the articles I
    linked to as well as google can provide the basics you need.

    The statistical code that accounts for network jitter and your pc's
    on-board clock inconsistencies is very advanced -- much more so in
    Linux than in XP. That's why financial insitutions use *nix (and more
    and more Linux) for their computers -- the transaction timestamps must
    be accurate to a degree that XP can't assure without external hardware
    support (a local gps or radio receiver) that can be a single point of
    failure without even more external support.

    I visited your web pages and found your meteor monitoring project
    interesting. The time you invest now in getting a grasp of ntp time
    servers will pay dividends in getting everything together -- your
    software interface to the scope, the software data recording, comparing
    data with others. It all depends on a common time reference -- a
    reference clock just as the ntpd servers provide.

    Most people don't need a tie to a reference clock -- accurate enough to
    not be late or enough to compare log times/file timestamps will do. If
    this is a serious effort at data collection, ntpd is the way to go as
    most (all?) other data will be timestamped via a reference clock
    connection.

    Good luck,
    prg
    email above disabled
     
    prg, Jan 8, 2005
    #31
  12. Lets see if this makes sense...

    You have two machines, which are networked but as a pair but
    they are isolated from other networks (no internet connection).
    You want them to maintain the same time, so that logged events
    on the two will track.

    One machine runs Linux and one machine runs Windows, and your
    initial thought was to use the Windows machine as your time
    standard, and sync the Linux box to it. That didn't work,
    because the Windows machine is not running a time server.

    Your options now are

    1) add time server software to the Windows machine

    2) add time server software to the Linux machine, *and*
    add software that will self regulate the system clock
    to be more accurate.

    I am unfamiliar with Windows, in any of it's many varieties. I
    am assuming (given what you originally said) that it does have
    software to 1) self regulate the clock, and 2) to sync to a
    networked time standard (via the NTP protocol). If your Windows
    box does *not* have those capabilities, you need to add the
    second one and should probably ignore the first one.

    Which is to say it will probably be easiest to self regulate the
    Linux box and sync the Windows box.

    Note that the accuracy you get depends on what you do to
    regulate the clock on the Linux box.

    You can simply speed it up or slow it down to get something
    "close enough", and then manually reset it whenever convenient
    (every day, week, or month... and the amount of error you get in
    between will depend on which you do). If being off by several
    minutes is not really a problem (as long as both machines are
    precisely the same), you don't really need to do anything to
    regulate the clock!

    You could add a modem, connect to the Internet at some specified
    interval, and set the time. You could also obtain a local time
    standard, such as a GPS clock, and sync to that (several hundred
    dollars at today's prices). In the very near future we can
    expect to see an atomic clock on a chip, suitable for
    installation in a PC, that will cost less than $200 initially
    and soon be under $100.

    http://www.nist.gov/public_affairs/releases/miniclock.htm

    Whatever, the Linux system is the one that is easiest to
    manipulate, and therefore should probably be the "master", with
    the Windows box synced to it.

    Make a decision on *exactly* what you want to do, and then
    others can give you assistance on specifics for doing it.
     
    Floyd L. Davidson, Jan 8, 2005
    #32
  13. W. Watson

    W. Watson Guest

    Good timeing. No pun intended. I delved into your previous message and have comments
    I guess they are meaningful to me. All the names are related to astronomy:

    Astro PC = PC on which I do most of my astronomical work. It has a Linux test bed,
    and a W2K side for my serious astronomical work--loaded with astronomy programs. Both
    the Linux boot and W2K boots are similarly named, I've spared you the longer names:
    AstroPC2004 and AstroPC2004-W2k.

    Meteor PC = PC exclusively for meteor work. As you saw from my web pages, this
    machine controls the all sky meteor video camera. It has two boots for Linux,
    operational one which has realtime linux, and a common installation of RHL9. It, as
    you observe below, is the focus of the time effort.

    Both of these machines are in my observatory outside my house, 100 feet away.

    Solarblast = My daily workhorse. XP Pro (SP2). All my internet work happens here.
    Internet browsing, mail, newsgroups, web page maintenance, Word doc, Excel, ...

    For the purposes of our discussion, let me call the two machines that I'm most
    concerned about for this effort: Xray (the *X*P machine and the Tbed (Linux test bed)
    machine. Is that OK?
    You have it. Yes, two versions as mentioned above. RHL9 and RHL9/Realtime.
    I have piles of paper and loose notes all over. :) At this point, I'll go for one
    second of accuracy. :) Realistically, I need to get into the same ball park as my
    partner in the meteor research work. He has camera at a college campus and uses their
    network to get his time. Those are details to work out later. A meteor can move a
    long way in a short period of time. Right now a reasonable ball park accuracy--maybe
    0.1 sec.
    Yes, I've got my eyes on a couple that look helpful.
    Are you referring to NTP here or adjtimex related Linux time commands? In fact, would
    I be in very good shape just using adjtimex?
    When I signed on to this work, they said you could do it with a little knowledge of
    Linux. Big understatement. :)
    Let me comment on your earlier material. About 30 minutes ago, I sat down at the
    monitor of Tbed, and made some notes as I skimmed along the pages from your material.

    I adjusted the clock to within 5 seconds of phone time. I understand that phone time
    may at times be not so accurate as true atomic time or WWV time. I have a SW rcvr if
    necessary. My attempt to synch with the calendar/time icon on the desktop didn't
    change a thing. Of course, this may be a hopeless way to do it, but it looks right.
    My shaky conception is that this operation will go to XRay for its time and then
    (maybe) out to the internet for its time.

    Let me stop here. It's getting late, and I see your other message that answers some
    of my questions about Lokkit and others that I asked not too many hours ago.

    I'll just briefly add these items:
    service iptables status produced quite a few lines of output.
    step-tickers has 192.168.0.3 in it. That's Xray.
    The script in /etc/init.d/ntpd looks quite close to what you showed.

    Well, I'm sacking out. Thanks for the interest and reading material culled from the
    internet.



    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #33
  14. W. Watson

    W. Watson Guest

    It's late. I just happened on your post right after a lengthy response to prg. See it
    for further information. I think he and I are on the same page. It looks like it was
    posted at 10:37.

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #34
  15. You are making it extremely difficult to help you, because the
    details you provide have little significance and information
    that does have significance is randomly sprinkled into your post
    in no particular order!

    You've posted how many articles, and I *still* can't really be
    sure just how accurate you want the time to be for your logging
    system. You've mentioned everything from within minutes to
    milliseconds, all of them as if that is what you need.

    If you are looking for absolute accuracy to less that 1 second,
    re-read the post of mine that you reponded to, and pay close
    attention to the discussion of how to get greater accuracy.

    You have basically two options, a full time connection to the
    Internet or a local time standard (e.g., a GPS unit). It
    doesn't make a lot of sense to use a Windows box as the local
    standard, so consider how you will apply one or the other
    solution to a Linux box.
     
    Floyd L. Davidson, Jan 8, 2005
    #35
  16. W. Watson

    W. Watson Guest

    I believe I have one thread on this NG on the topic of using NTP to time sync. It
    certainly has developed side branches. Perhaps your NG reader isn't capable of
    working out the thread? I'm using Moz 1.7. What I see is a screen that shows Subject,
    Sender, Date, time, etc. However, on the very left there's a little double folder
    icon in the header that if one clicks, the posting order is juggled to clearly show
    the tree structure of the thread. I have no trouble seeing the branches, who has
    recented posted on any subthread and who they are.

    Forget time accuracy. At this point there is *exactly one goal*. *Goal*: How do I get
    the Linux box to get time from the XP box via the internet? If someone can tell me
    this cannot be done or that the time gotten that is so crude that I cannot get better
    than one second accuracy, then I'll open my ears to other considerations. Otherwise,
    there's a steady drum beat to the goal mentioned. Two machines, one modem (on XP),
    and one internet connection. If the message that prg posted and I directed you to
    doesn't answer your questions, then ask. Right now my main focus is on why doesn't my
    attempt to use ntpdate produce a time change on the Linux box?
    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #36
  17. W. Watson

    Tauno Voipio Guest

    My ISP may block the server from outside requests.

    Thanks for the compliment, but there is no sense
    in running NTP sync to an overseas server.

    For your astronomic work, I'd seriously consider
    having one Linux machine with ntpd running continuously.
    The algorithms in NTP act as a long-time PLL
    (phase-locked loop) to adjust both the clock
    rate and time to sync. It takes from several
    hours to days to get to the final sync.

    Please get and read prof. Mills' papers.

    Best wishes for the astronomy work!
     
    Tauno Voipio, Jan 8, 2005
    #37
  18. Use "ntpdate -d <timeserver>" to show debug information. If you don't
    understand the output, post it to the group.
     
    Markku Kolkka, Jan 8, 2005
    #38
  19. W. Watson

    W. Watson Guest

    I now have ntp servers in California. Don't recall Mills' papers coming up in this
    discussion. Perhaps in prg's responses.

    Here's my total focus right now. Why can't I synch off of the NTP machine from linux?
    I'd like to understand why that is the case before considering anything else.

    Here's what I know at the moment. From the Linux machine, I can fire up
    redhat-config-date (I think that's the right name for the tool). I can specify a
    location for the ntp server. One of them, which I added to the list, is 192.168.0.3,
    which is my XP machine. Another, provided by RH, is clock1.redhat.com.

    I deliberately set the clock off by 15 seconds. If I specify 192.xxxx, I do not get
    any correction. I then dial into my ISP from the Linux machine (note that the final
    machine for the synch is not going to have a modem or otherwise any internet
    connection.) I now use the tool again, but specify the clock1 entry. It resets the
    clock to the correct time. I again set the clock off by 10 seconds or so, and do the
    same with 192.xxxxx. Nothing. Either XP isn't set up to deal with NTP or the request
    never makes it to XP. The question remains, why doesn't this work?

    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #39
  20. W. Watson

    W. Watson Guest

    OK, I've look at this note an hour ago. See my intermixed comments below.
    I get a substantial # of lines of output.
    I think you've missed my messages on this approach--made in another part of the main
    thread. I've done the same through the panel at the bottom of the desk top. Using the
    cmd line tool is a bit more convenient.
    Here's what I see in the appropriate files:
    ntp-servers
    192.168.0.3
    clock.redhat.com
    clock1.redhat.com
    clock2.redhat.com
    drift
    0.000
    See below. I use this in some testing.
    Looks familiar to what I'm getting. I'll double check later. It just goes zipping by
    quickly. I'm not close to the obs computer right now.
    Here's my total focus right now. Why can't I synch off of the NTP machine from linux?
    I'd like to understand why that is the case before considering anything else.

    Here's what I know at the moment. From the Linux machine, I can fire up
    redhat-config-date. I can specify a location for the ntp server. One of them, which I
    added to the list, is 192.168.0.3, which is my XP machine. Another, provided by RH,
    is clock1.redhat.com.

    I deliberately set the clock off by 15 seconds. If I specify 192.xxxx, I do not get
    any correction. I then dial into my ISP from the Linux machine (note that the final
    machine for the synch is not going to have a modem or otherwise any internet
    connection.) I now use the tool again, but specify the clock1 entry. It resets the
    clock to the correct time. I again set the clock off by 10 seconds or so, and do the
    same with 192.xxxxx. Nothing. Either XP isn't set up to deal with NTP or the request
    never makes it to XP. The question remains, why doesn't this work?


    --
    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: <home.earthlink.net/~mtnviews>
     
    W. Watson, Jan 8, 2005
    #40
    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.