centos6.5 安装时间服务器
---------服务端口UDP123
1、查看系统是否已经安装ntp服务组件:
rpm -qa | grep "ntp"
2、 yum安装
yum -y install ntp
3、配置NTP服务
[root@localhost ~]# egrep -v "^$|#" /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict 127.0.0.1 #<==允许本机的一切操作
restrict -6 ::1 #同步时间.但是拒绝让他们修改服务器上的时间
restrict 172.16.1.0 mask 255.255.255.0 nomodify #允许允许局域网内所有client连接到这台服务器
server ntp1.aliyun.com
server ntp2.aliyun.com
server ntp3.aliyun.com
server ntp4.aliyun.com
server ntp5.aliyun.com
server ntp6.aliyun.com #<==同步公网的时间
server 127.127.1.0 #<==如果无法连接公网,则使用自己本身的时间作为标准时间。
fudge 127.127.1.0 stratum 10 #<==设置stratum级别
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
4、添加开机启动
[root@localhost ~]# chkconfig ntpd on
============
5、让硬件同步时间
[root@localhost ~]# cat /etc/sysconfig/ntpd
# Drop root to id 'ntp:ntp' by default.
OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
SYNC_HWCLOCK="yes"
6、开放UDP123端口
iptables -I INPUT -p udp --dport 123 -j ACCEPT