NTP service setup under Linux

Source: Internet
Author: User
Tags net time new york time zone

In order to achieve time synchronization, we need to use the NTP (Network Protocol) protocol.

Simply put, NTP is the protocol used to keep the system in sync with a precise time source.

We need to establish a server that can provide accurate time, all the computers in the LAN unified Time synchronization, calibration through this time server.

How to set up a Linux time Zone:

/usr/share/zoneinfo: This is a directory in which the time setting files for each major time zone are specified, for example, the time zone settings file for mainland China is/usr/share/zoneinfo/asia/shanghai.

We can use the Zdump command if we want to see the current time for each zone.

For example: See Japan, Shanghai, and New York time separately.

When we enter the date command to see the time, which time zone we are in, we can then copy to/etc/localtimezone (/usr/share/zoneinfo) by locating our temporal zone file under the Or make a symbolic link) to change your time zone

For example: Change the time zone to the New York time zone and view the current times by date.

Change the time zone to Japan's time zone and view the current times by date.

Change the time zone to the time zone in Shanghai and view the current times by date.

Settings for NTP server:

Edit the configuration file for NTP/etc/ntp.conf

About the Permission Settings section

The setting of the permission is mainly set by the Restrict parameter, the main syntax is:

Restrict IP address mask Subnet mask parameter

Where IP can be an IP address or default, default means all IP

The parameters are as follows:

Ignore: Turn off all NTP Online Services

Nomodify: The client cannot change the time parameters on the server side, but the client can perform the network calibration via the server.

Notrust: The client source will be treated as untrusted subnet unless authenticated

Noquery: Do not provide a time query for the client

Notrap: No trap remote login feature, trap service is a remote time log service

Nopeer: Provide time service, but not as peer

Kod: Sending Kiss-of-death messages to unsafe visitors

Note: If the parameter is not set, it means that there is no limit to the IP (or subnet)!

Settings for the parent time server:

Since the NTP server we are configuring requires a more accurate NTP server on the network to update its time, a parent time server is configured on our NTP server to calibrate

Use the server parameter to set the parent time server, the syntax is:

Server + IP address or domain name [prefer]

The IP address or domain name is the parent time server we specified, and if the server parameter is finally added prefer, it means that our NTP server is mainly calibrated with the host time of the unit.

To resolve the delivery delay for NTP server calibration time:

Use the Driftfile parameter setting:

Driftfile file name

The time that is spent in contacting the parent time server is recorded in the file following the Driftfile parameter.

Note: The files that follow the driftfile need to use the full path file name, cannot be a link file, and the permissions of the file need to be set to NTPD daemon can write.

Use of NTP clients:

Linux systems:

Execution Ntpdate:

Ntpdate 10.1.3.51 where 10.1.3.51 is the IP of the NTP server

Do not forget to use the Hwclock command to write time to the BIOS

Hwclock-w

If you want to schedule time calibration, you can use the Crond service to do it regularly.

Edit/etc/crontab File

Add the following line:

8 * * * root/usr/sbin/ntpdate 10.1.3.51; /sbin/hwclock-w where 10.1.3.51 is the IP address of the NTP server

Then restart the Crond service

Systemctl Restart Crond

In this way, every day the Linux system will automatically perform network time calibration.

Windows System:

Double-click the time on the desktop taskbar to bring up the date and Time Properties window

Select Internet time, fill in the server with the IP address or domain name of your NTP server, then click Update Now and your system time will be updated immediately. If you want to update regularly, check the upper left corner automatically with the Internet time server and click Apply in the lower right corner.

Yy-2-3.tif

If it is not a Windows XP system, but the NTP server is also a samba server, you do not need to install any time synchronization software for Windows, because Windows clients can use NET time\\ time server IP or server NetBIOS name/ Set/yes to synchronize. You can place the command in the startup item of the Start menu and automatically sync when you start Windows.

Because the net TIME command synchronizes times with the NetBIOS over TCP/IP protocol, the Windows Client installation time synchronization software is required when the NTP server is different from the Samba server. This is a lot of software, the use is very simple, readers can search the Internet.

Reference: http://www.cnblogs.com/oskb/p/3848714.html

NTP service setup under Linux

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.