FreeBSD system time synchronization and NTP service provision

Source: Internet
Author: User

[Switch] Provision of time synchronization and NTP service for FreeBSD system

China National Time Service Center Time Server IP Address: 210.72.145.44

Http://www.cnfug.org/journal/archives/000038.html

Original article of NTP at www.cnfug.org:

Tonight <dingxin@sea.plala.or.jp>

If you ignore the computer time, there will be an error soon.
This error is reflected in the time stamp of the email sending time, and in the posting time of your forum post. At least I have encountered this problem.
An NTP (Network Time Protocol) server is deployed on the network to provide the current time. We can synchronize the local time with the NTP server time.

The purpose is as follows:
1. Use ntpdate for time correction at startup.
2. during startup, the time correction is performed through ntpd, and the time correction is performed for each client computer at the same time.
3. If the NTP server cannot be found, use local time and synchronize the client.

There are more than 100 NTP servers around the world. Find the one closest to you from the address below.

Http://www.eecis.udel.edu /~ Mills/NTP/clock1a.html
I have selected two

Clock.nc.fukuoka-u.ac.jp 133.100.9.2.
Clock.tl.fukuoka-u.ac.jp 133.100.11.8.

Steps:

FreeBSD has two standard NTPProgramThe first is ntpdate.
Ntpdate obtains the time point from the NTP server and adjusts the local time point.

# Ntpdate clock.nc.fukuoka-u.ac.jp
9 Oct 18:12:23 ntpdate: Step time server 133.100.9.2 offset-19.112674
The error is about 19 seconds.

Automatic Setting

# Grep ntpdate/etc/defaults/rc. conf>/etc/rc. conf
# Vi/etc/rc. conf
Ntpdate_enable = "yes" # Run ntpdate to sync time on boot (or no ).
Ntpdate_program = "ntpdate" # path to ntpdate, if you want a different one.
Ntpdate_flags = "clock.nc.fukuoka-u.ac.jp" # flags to ntpdate (if enabled ).
After the restart, it runs. Of course, the setting is not complete and you do not have to start it urgently.

Another standard NTP program of FreeBSD, NTP
The NTP program provides time points to other PCs while obtaining NTP time points.

Add the NTP. conf file:

I chose two NTP servers for the standard time.

Clock.nc.fukuoka-u.ac.jp 133.100.9.2.
Clock.tl.fukuoka-u.ac.jp 133.100.11.8.

At the same time, it is no problem to specify multiple servers. The system will automatically select a trusted server.
Here, we will directly specify an IP address to avoid extra DNS packet transmission.
Server line server 127.127.1.0 is the address used in local time reference. Then, use fudge to specify the class number as 5 to reduce its priority.

Then, use restrict to specify the corresponding rules for each IP address.
Finally, specify the drift document storage address for wavelength correction. The specific meaning of this command line is unclear. However, if not, the time correction will be slow.

# Vi/etc/NTP. conf
Server 133.100.9.2 # clock.nc.fukuoka-u.ac.jp
Server 133.100.11.8 # clock.tl.fukuoka-u.ac.jp
Server 127.127.1.0
Fudge 127.127.0.1 stratum 5
Restrict default ignore
Restrict 127.0.0.0 mask 255.0.0.0
Restrict 192.168.1.0 mask limit 255.0 noquery nopeer notrust
Restrict 133.100.9.2 noquery
Restrict 133.100.11.8 noquery
Driftfile/etc/ntpd. Drift
Start test

# Ntpd-P/var/run/ntpd. PID
# Tail/var/log/messages
Oct 9 16:46:56 chiwawa ntpd [89409]: NTPD 4.1.0-A Thu Apr 3 08:26:24 GMT 2003 (1)
Oct 9 16:46:56 chiwawa ntpd [89409]: Kernel Time discipline status 2040
......
Oct 9 16:50:10 chiwawa ntpd [89409]: time set-0.189546 s
You can see similar results.

Run the test
Use the ntpq command to run ntpd.

# Ntpq-P
Remote refID st t when poll reach delay offset Jitter
========================================================== ==============================================
* Clock. nc. fukuok. GPS. 1 U 43 64 37 19.067-6.884 10.339
+ Clock. TL. fukuok. GPS. 1 U 36 64 35 19.670-3.259 2.341
Local (0) Local (0) 5 L 45 64 37 0.000 0.000
It takes a little time to complete the calibration at the start time. * Is the first alternate, and + is the second.
After the local time correction is completed, the time correction service can be provided for other PCs.

Automatic Start setting
After completing the preceding settings and confirming that the operation is correct:

# Grep ntpd/etc/defaults/rc. conf>/etc/rc. conf
# Vi/etc/rc. conf
Xntpd_enable = "yes" # Run ntpd Network Time Protocol (or no ).
Xntpd_program = "ntpd" # path to ntpd, if you want a different one.
Xntpd_flags = "-P/var/run/ntpd. PID" # flags to ntpd (if enabled ).

Append the above three lines to RC. conf and modify them.
Client PC settings:
UNIX OS

# Vi/etc/NTP. conf
Server [local NTP server IP address] prefer
Driftfile/etc/ntpd. Drift
Or append the following content to crontab, so that it is automatically updated every hour.
# Vi/etc/crontab
0 ***** root ntpdate [NTP server IP]>/dev/null 2> & 1
Of course, your host is actually a client, which can also be used.
Windows

Seiko's website has downloaded software, but it is Japanese.
Http://www.seiko-p.co.jp/systems/down/time.html
Windows2000 comes with the SNTP function. Please study it yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.