Configure NTP in Linux to set up a local time server

Source: Internet
Author: User
Article Title: Configure NTP in Linux to set up a local time server. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Configure NTP to set up a local time server

NTP is a protocol used to synchronize time between the system and a precise time source. in Linux, we can use the Network Time Protocol to keep our system accurate.

Installation:

# Yum install ntp

Or find the ntp rpm package installation from the installation disk

When you only have one server that can be connected to the Internet, add

# Crontab-e

Add a row:

*/15 * ntpdate 210.72.145.44

210.72.145.44 is the address of the Chinese National Time Service Center server, so that the server can be synchronized with the National Time Service Center.

To set up a local time server, you only need to modify several simple configurations in the/etc/ntp. conf file. The following is the configuration I added:

# Add by Fengshihua

Server 210.72.145.44 prefer)

Server 218.21.130.42 (IP address of cn.pool.ntp.org)

Restrict 192.168.100.0 mask 255.255.255.0 nomodify (Intranet Communication allowed)

Restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap noquery notrust (shields other IP addresses from updating the time)

Others remain unchanged by default.

To enable the NTP service to automatically start during system boot, run:

# Chkconfig ntpd on

The command to start/disable/restart NTP is:

#/Etc/init. d/ntpd start

#/Etc/init. d/ntpd stop

#/Etc/init. d/ntpd restart

Write the synchronized time to CMOS.

Vi/etc/sysconfig/ntpd

SYNC_HWCLOCK = yes

Remember to restart the service every time you modify the configuration file to make the configuration take effect. You can run the following command to check whether the NTP service is started. You should be able to get a process ID:

# Pgrep ntpd

Run the following command to check the synchronization status of the Time Server:

# Ntpq-p

You can also use ntpstat to view some synchronization statuses. Use netstat-ntlup to view port usage!

It takes 5 to 10 minutes to update the client from the server after the client is installed!

Client settings:

# Crontab-e

Add a row:

*/15 * ntpdate Server IP address.

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.