# 同步时间

# 安装ntp

yum -y install ntpdate

# 同步时间

ntpdate ntp.aliyun.com

ntpdate cn.ntp.org.cn

# 本地搭建ntp服务

开启本地ntp服务器,此服务器ip为 192.168.188.100

service ntpd start
vi /etc/ntp.conf

#========权限控制============
restrict default kod nomodify notrap nopeer noquery 拒绝IPV4用户
restrict -6 default kod nomodify notrap nopeer noquery 拒绝IPV6用户
restrict 210.72.145.44 授权国家授时中心服务器访问本地NTP
restrict 133.100.11.8 授权133.100.11.8访问本地NTP
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.188.2 mask 255.255.255.0 nomodify 本地网段授权访问
#=========源服务器===========
server cn.ntp.org.cn prefer 指定上级更新时间服务器,优先使用这个地址
#=========差异分析===========
driftfile /var/lib/ntp/drift
keys /etc/ntp/keys

客户端同步时间

ntpdate 192.168.188.100

其实,要同步时间,需要一台开启了ntp服务的服务器作为基准服务器,也就是其他的服务器需要找到一个正确的时间来调整自己的时间。 这种适合不能连接内网的服务器,只有内部网络的服务器来同步服务器。

如果可以访问外网,可以直接使用 ntp.aliyun.com , cn.ntp.org.cn 这些公共的基准服务器作为同步服务器。

关于评论

评论前请填好“昵称”、“邮箱”这两栏内容,否则不会收到回复,谢谢!