Time Syncronization

From MiOS
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
The '''Vera '''units use by default '''rdate '''to synchronize the time.<br>
+
The '''Vera '''units use by default '''rdate '''to synchronize the time.<br> Rdate is a client program which uses the Time protocol. Rdate servers are running the Time service protocol on '''port 37''' which conforms to RFC 868. Clients can use either TCP or UDP.<br> The '''Time Protocol''' is not related or compatible with '''Network Time Protocol''' (RFC 958). This service does one time query and synchronization.<br>  
Rdate is a client program which uses the Time protocol. Rdate servers are running the Time service protocol on '''port 37''' which conforms to RFC 868. Clients can use either TCP or UDP.<br>
+
<pre>Rdate use Time Protocol (RFC858) <u>'''which is not compatibile with ntpclinet/openntp'''</u> Network Time Protocol (RFC958).
The '''Time Protocol''' is not related or compatible with '''Network Time Protocol''' (RFC 958). This service does one time query and synchronization.<br>
+
</pre>  
Rdate use Time Protocol (RFC858) <u>'''which is not compatibile with ntpclinet/openntp'''</u> Network Time Protocol (RFC958).<br>
+
== <span id="Prerequisites" class="mw-headline">Prerequisites</span> ==
Time Servers are listening on port 37 and Network Time Servers on 123.<br>  
+
'''Note:''' In order for you Vera unit to successfully syncronize its time you have to allow connections from it to the time servers on port 37 for rdate and port 123 for ntpclient if you install it.<br>
+
  
<u>To check the servers used to synchronize time use</u>&nbsp;:<br>  
+
*Vera hardware
 +
*Root acces to your OpenWRT
 +
 
 +
<br>
  
'''rdate -p server'''
+
== <span id="Instructions" class="mw-headline">Instructions</span> ==
  
 +
Gain ssh access to your vera2 (root) and use the password that is provided on the bottom of your vera2. More info on how to can be found here:[http://wiki.micasaverde.com/index.php/Logon_Vera_SSH [1]]
 +
 +
Time Servers are listening on port 37 and Network Time Servers on 123.<br> '''Note:''' In order for you Vera unit to successfully syncronize its time you have to allow connections from it to the time servers on port 37 for rdate and port 123 for ntpclient if you install it.<br>
 +
 +
<u>To check the servers used to synchronize time use</u>&nbsp;:<br>
 +
<pre>''rdate -p server''</pre>
 
''The -p switch prints the date and time''.<br>  
 
''The -p switch prints the date and time''.<br>  
  
 
<u>To set the time from that server use this command:</u>  
 
<u>To set the time from that server use this command:</u>  
 
+
<pre>''rdate -l -s server''</pre>
'''rdate -l -s server'''
+
 
+
 
''The -l switch allows for logging results to Syslog, -s sets the system time.''  
 
''The -l switch allows for logging results to Syslog, -s sets the system time.''  
  
<br> There is no worldwide list of Time servers available. Many, but not all, Network Time Protocol (NTP) servers also serve Time on port 37. There is a list of NTP servers here&nbsp;: http://support.ntp.org/bin/view/Servers/WebHome<br>  
+
There is no worldwide list of Time servers available. Many, but not all, Network Time Protocol (NTP) servers also serve Time on port 37. There is a list of NTP servers here&nbsp;: http://support.ntp.org/bin/view/Servers/WebHome<br>  
  
 
The National Institute of Standards and Technology (United States Gov't) offers about a dozen Time servers to the public. Their server list is available here: http://tf.nist.gov/tf-cgi/servers.cgi#<br>  
 
The National Institute of Standards and Technology (United States Gov't) offers about a dozen Time servers to the public. Their server list is available here: http://tf.nist.gov/tf-cgi/servers.cgi#<br>  
  
 
Here is a list of working servers (at this moment):  
 
Here is a list of working servers (at this moment):  
 
+
<pre>nist1.aol-va.symmetricom.com
<br>  
+
nist1.columbiacountyga.gov
 
+
nist1-atl.ustiming.org
nist1.aol-va.symmetricom.com<br>nist1.columbiacountyga.gov<br>nist1-atl.ustiming.org<br>nist1-chi.ustiming.org<br>nist.expertsmi.com<br>nisttime.carsoncity.k12.mi.us<br>nist1-lnk.binary.net<br>wwv.nist.gov<br>time.nist.gov<br>utcnist.colorado.edu<br>utcnist2.colorado.edu<br>ntp-nist.ldsbc.edu<br>nist1-lv.ustiming.org<br>nist-time-server.eoni.com<br>nist1.aol-ca.symmetricom.com<br>nist1.symmetricom.com<br>nist1-sj.ustiming.org<br>nist1-la.ustiming.org<br>
+
nist1-chi.ustiming.org
 
+
nist.expertsmi.com
<br>  
+
nisttime.carsoncity.k12.mi.us
 
+
nist1-lnk.binary.net
 +
wwv.nist.gov
 +
time.nist.gov
 +
utcnist.colorado.edu
 +
utcnist2.colorado.edu
 +
ntp-nist.ldsbc.edu
 +
nist1-lv.ustiming.org
 +
nist-time-server.eoni.com
 +
nist1.aol-ca.symmetricom.com
 +
nist1.symmetricom.com
 +
nist1-sj.ustiming.org
 +
nist1-la.ustiming.org
 +
</pre>
 
To test on your '''Vera '''unit which servers are working, log in by ssh and then create a new file called timeservers.txt in /tmp with this command&nbsp;:<br>  
 
To test on your '''Vera '''unit which servers are working, log in by ssh and then create a new file called timeservers.txt in /tmp with this command&nbsp;:<br>  
 
+
<pre>''touch /tmp/timeservers.txt''
'''touch /tmp/timeservers.txt'''<br>  
+
</pre>
 
+
 
Then edit it and copy the servers from the list using vim, and then run this command at least 5 times&nbsp;:<br>  
 
Then edit it and copy the servers from the list using vim, and then run this command at least 5 times&nbsp;:<br>  
 
+
<pre>''while read server; do echo -n "Server $server&nbsp;:"; rdate -p $server &amp;&amp; echo "OK" || echo "FAILED"; done &lt; /tmp/timeservers.txt ''
'''while read server; do echo -n "Server $server&nbsp;:"; rdate -p $server &amp;&amp; echo "OK" || echo "FAILED"; done &lt; /tmp/timeservers.txt '''<br>  
+
</pre>
 
+
 
After that compare the results and pick the servers that only display OK, these will be the most reliable, and then add them to the list here /etc/config/timeserver .<br>  
 
After that compare the results and pick the servers that only display OK, these will be the most reliable, and then add them to the list here /etc/config/timeserver .<br>  
  
 
To sync the time use the following command&nbsp;:<br>  
 
To sync the time use the following command&nbsp;:<br>  
 
+
<pre>'' ash -x /usr/bin/sync_time.sh''
'''&nbsp;ash -x /usr/bin/sync_time.sh'''<br>  
+
</pre>
 
+
 
<br>  
 
<br>  
 +
==
  
'''Creating a local timeserver'''
+
If you want to create a local time servers you can use '''xinetd '''and you can read more about it here [http://ecloud.org/index.php?title=Rdate_server [2]]<br>  
 
+
<br> If you want to create a local time servers you can use '''xinetd '''and you can read more about it here http://ecloud.org/index.php?title=Rdate_server <br>  
+
  
 
Once all the settings have been made you need to restart '''xinetd '''by using this command&nbsp;:  
 
Once all the settings have been made you need to restart '''xinetd '''by using this command&nbsp;:  
 +
<pre>''/etc/init.d/xinetd reload ''
 +
</pre>
 +
'''<br>'''
 +
Installing the NTP client<br> ==
 +
Run the following commands to install the NTP client by ssh:<br>
 +
<pre>''opkg update''
 +
</pre> <pre>''opkg install ntpclient''
 +
</pre><pre>'''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />''''''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />''''''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />'''''for i in 0 1 2 3; do ntpclient -c 1 -p 123 -h $i.openwrt.pool.ntp.org; done
 +
''</pre><pre>''/etc/init.d/ntpclient restart
 +
''</pre>
  
'''/etc/init.d/xinetd reload '''<br>  
+
'''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />'''To check if the ntp client is running use this command:<br>
 +
<pre>''ps fax | grep ntp''</pre>
 +
'''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />'''If you see this message than you've successfully installed the NTP client:<br>
 +
<pre>4188 root      1068 S    /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org
 +
14454 root      1672 S    grep ntp
 +
</pre>
 +
To edit the ntp.conf file you can use the '''vim '''editor:
 +
<pre>''vim /etc/ntp.conf''</pre>
 +
To view the current entries in your ntp.conf type:<br>
 +
<pre>''cat /etc/ntp.conf''
 +
</pre>
  
<br>
 
  
<span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;" id="internal-source-marker_0.35288017772422464">How to install NTP:</span><br>
+
'''''Note: Please remember to keep the same format of the file when you edit it.'''''
 
+
Please use these commands to install NTP:
+
 
+
<span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">opkg update</span><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">opkg install ntpclient</span><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">for i in 0 1 2 3; do ntpclient -c 1 -p 123 -h $i.openwrt.pool.ntp.org; done</span><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">/etc/init.d/ntpclient restart</span><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">ps fax | grep ntp</span><br><br>
+
 
+
After the last command you should see this in the console:
+
 
+
<br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">14188 root &nbsp;&nbsp;&nbsp;&nbsp; 1068 S&nbsp;&nbsp;&nbsp; /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org</span><br><span style="font-size:15px;font-family:Arial;color:#000000;background-color:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">14454 root &nbsp;&nbsp;&nbsp;&nbsp; 1672 S&nbsp;&nbsp;&nbsp; grep ntp</span>
+
 
+
If you do then you've successfully installed the NTP client on your Vera unit.
+
 
+
<br>
+
 
+
<br>
+

Revision as of 15:32, 8 May 2012

The Vera units use by default rdate to synchronize the time.
Rdate is a client program which uses the Time protocol. Rdate servers are running the Time service protocol on port 37 which conforms to RFC 868. Clients can use either TCP or UDP.
The Time Protocol is not related or compatible with Network Time Protocol (RFC 958). This service does one time query and synchronization.

Rdate use Time Protocol (RFC858) <u>'''which is not compatibile with ntpclinet/openntp'''</u> Network Time Protocol (RFC958).

Prerequisites

  • Vera hardware
  • Root acces to your OpenWRT


Instructions

Gain ssh access to your vera2 (root) and use the password that is provided on the bottom of your vera2. More info on how to can be found here:[1]

Time Servers are listening on port 37 and Network Time Servers on 123.
Note: In order for you Vera unit to successfully syncronize its time you have to allow connections from it to the time servers on port 37 for rdate and port 123 for ntpclient if you install it.

To check the servers used to synchronize time use :

''rdate -p server''

The -p switch prints the date and time.

To set the time from that server use this command:

''rdate -l -s server''

The -l switch allows for logging results to Syslog, -s sets the system time.

There is no worldwide list of Time servers available. Many, but not all, Network Time Protocol (NTP) servers also serve Time on port 37. There is a list of NTP servers here : http://support.ntp.org/bin/view/Servers/WebHome

The National Institute of Standards and Technology (United States Gov't) offers about a dozen Time servers to the public. Their server list is available here: http://tf.nist.gov/tf-cgi/servers.cgi#

Here is a list of working servers (at this moment):

nist1.aol-va.symmetricom.com
nist1.columbiacountyga.gov
nist1-atl.ustiming.org
nist1-chi.ustiming.org
nist.expertsmi.com
nisttime.carsoncity.k12.mi.us
nist1-lnk.binary.net
wwv.nist.gov
time.nist.gov
utcnist.colorado.edu
utcnist2.colorado.edu
ntp-nist.ldsbc.edu
nist1-lv.ustiming.org
nist-time-server.eoni.com
nist1.aol-ca.symmetricom.com
nist1.symmetricom.com
nist1-sj.ustiming.org
nist1-la.ustiming.org

To test on your Vera unit which servers are working, log in by ssh and then create a new file called timeservers.txt in /tmp with this command :

''touch /tmp/timeservers.txt''

Then edit it and copy the servers from the list using vim, and then run this command at least 5 times :

''while read server; do echo -n "Server $server :"; rdate -p $server && echo "OK" || echo "FAILED"; done < /tmp/timeservers.txt ''

After that compare the results and pick the servers that only display OK, these will be the most reliable, and then add them to the list here /etc/config/timeserver .

To sync the time use the following command :

'' ash -x /usr/bin/sync_time.sh''


==

If you want to create a local time servers you can use xinetd and you can read more about it here [2]

Once all the settings have been made you need to restart xinetd by using this command :

''/etc/init.d/xinetd reload ''


Installing the NTP client
== Run the following commands to install the NTP client by ssh:

''opkg update''
''opkg install ntpclient''
'''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />''''''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />''''''<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />'''''for i in 0 1 2 3; do ntpclient -c 1 -p 123 -h $i.openwrt.pool.ntp.org; done
''
''/etc/init.d/ntpclient restart
''

<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />To check if the ntp client is running use this command:

''ps fax | grep ntp''

<span style="font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); background-color: transparent; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline;" />If you see this message than you've successfully installed the NTP client:

4188 root      1068 S    /usr/sbin/ntpclient -i 600 -s -l -D -p 123 -h 0.openwrt.pool.ntp.org
14454 root      1672 S    grep ntp

To edit the ntp.conf file you can use the vim editor:

''vim /etc/ntp.conf''

To view the current entries in your ntp.conf type:

''cat /etc/ntp.conf''


Note: Please remember to keep the same format of the file when you edit it.

Personal tools