NTP全称为{(Network Time Protocol(NTP)},用于在互联网或局域网个PC或服务器之间同步时间,且可实现加密方式同步时间,在IDC或机房当中时间同步非常重要,但是又不能去互联网同步时间,因此在内网搭建一台自己的NTP Server则十分有必要:


1、安装服务:

ntp:主服务程序

ntpdate:时间同步命令

ntp 时间服务器

2、编辑配置文件:

/etc/ntp.conf

restrict 127.0.0.1

restrict 192.168.10.0 mask 255.255.255.0 nomodify  notrap #允许访问的网段

restrict -6 ::1


互联网上的ntp时间服务器,可以是IP或者主机名(需要能解析出来,用于同步本机的时间):

server 0.centos.pool.ntp.org

server 1.centos.pool.ntp.org

server 2.centos.pool.ntp.org


如果无法同步互联网上的时间则以本机的时间为准:

server  127.127.1.0     # local clock 

fudge   127.127.1.0 stratum 10


3、启动服务并验证:

ntp 时间服务器

当NTP服务正常启用之后,123端口会被打开,即NTP的端口号为123端口。


4、在客户机测试:

ntp 时间服务器

需要看到能够同步成功的信息即可!

注:本NTP Server关闭了iptables和Selinux。