linux搭建ntp服务器-添加交换机客户端,windows客户端
由于生产环境需要ntp时间同步服务器,故分享成果
[root@localhost ~]# cat /etc/redhat-release
CentOS release 6.8 (Final)
[root@localhost ~]# rpm -qa |grep ntp
ntp-4.2.6p5-15.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-15.el6.centos.x86_64
如果没安装,请输入命令安装
yum install -y ntp
cat /etc/ntp.conf #修改配置文件如下图
加入开机自启动
chkconfig –list ntpd
chkconfig ntpd on
chkconfig –list ntpd
重启服务并查看服务状态
/etc/init.d/ntpd status
/etc/init.d/ntpd restart
/etc/init.d/ntpd status
查询监听端口协议
netstat -lnptu|grep ntp
Ntpstat
查看同步服务使用状态
ntpq -p
查看防火墙状态
service iptables status
如果防火墙未关闭,请直接关闭防火墙和selinux
如果需要开启防火墙,请放行ntp服务端口
查看日志
cat /var/log/messages
———————————————交换机同步ntp ——————————————–
ntp服务器IP: 172.30.241.176
交换机上同步命令
ntp-service unicast-server 172.30.241.176 preference
前提
交换机要能ping通服务器IP
注意:
时区是不能同步的,只能同步时钟,若是时区不一致导致时钟有差异,请自行修改客户端时区
———————————————-windows同步ntp ——————————————
ntp服务器IP: 172.30.241.176
控制面板>时钟和区域>设置时间和日期