Linux Configuration NTP server

Source: Internet
Author: User

Linux configuration NTP server

Background

When the server is more, time is accurate or not, the same is a big problem. Although this problem is always overlooked, it is necessary to unify the time. Here's how to configure a Linux time server within a LAN.

Configuration of the environment and requirements:


1. Assume that a Linux machine time server with IP 192.168.0.240 is in the 192.168.0.0 network segment.

2.192.168.0.240 Server can Sisu network, can be synchronized with the more authoritative public network time server

3. Automatically synchronizes time to 192.168.0.240 per hour for other machines in the same network segment

Configuration method

One, configure the NTP server (assuming that the IP address of the server you want to configure is 192.168.0.240)

The main configuration file for the 1.NTP server is/etc/ntp.conf now for the/etc/ntp.conf


#配置前做好备份

CD/ETC/MV ntp.conf ntp.bak.conf

2.vi/etc/ntp.conf (Below is the contents of the ntp.conf file)

#设置此服务器同上层服务器做时间同步的IP地址, prefer means the preferred IP address

#经试验, the next few times the server is pretty fast.

Server 210.72.145.44 prefer server 218.21.130.42 server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2. asia.pool.ntp.org


The time spent #记录上次的NTP server joins the upper NTP server

Driftfile/etc/ntp/drift


#设置默认策略为允许任何主机进行时间同步

Restrict default Ignore


#设置允许访问此时间服务器的时间服务的IP地址

#根据自己实际情况配置

Restrict 127.0.0.1 Restrict 192.168.10.2# Specifies a machine time synchronization restrict 192.168.0.0 mask 255.255.255.0 #允许192.168.0.0/ 254 in-subnet host time synchronization restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap #允许任何主机跟进行时间同步


#指定阶层编号为10, reducing its priority.

Fudge 127.127.1.1 Stratum 10


#设置ntp日志的path

statsdir/var/log/ntp/


#设置ntp日志文件

Logfile/var/log/ntp/ntp.log


Maintenance of 3.NTP Server

----added as a service

Chkconfig--level 345 ntpd on

----Start

Service NTPD Start

Or

/ETC/RC.D/INIT.D/NTPD start

----Stop

Service NTPD Stop

Or

/ETC/RC.D/INIT.D/NTPD stop

----Management Commands

Ntpq–p #查看本机和上层服务器的时间同步结果 ntptrace #可以用來追踪某台时间服务器的时间对应关系 ntpdate IP #客户端要和NTP server for clock synchronization. /var/log/ntp/ntp.log #查看ntp日志


Second, configure the client

1.LINUX Client: (Time-required machine in LAN)

echo "*/1 * * * * root/usr/sbin/ntpdate192.168.0.240;/sbin/hwclock-w" >>/etc/crontab clock synchronization with NTP server every hour, and write to the native Bios2.solaris client: echo "5 * * * */usr/sbin/ntpdate 192.168.0.240" >>/etc/crontab


This article from "Nicol Lock Silk Sorrow" blog, please make sure to keep this source http://smoke520.blog.51cto.com/9256117/1835852

Linux Configuration NTP server

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.