安装NTP Server
sudo apt-get install ntp
配置conf文件
sudo vimd /etc/ntp.conf# 允许本地网络的客户端访问,但是不允许本地机器修改server的时间
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
启动服务
sudo service ntp start
你可以使用以下命令来检查ntpd的状态和同步信息:
ntpq -p
为了确保ntpd在系统启动时自动启动,你可以运行:
sudo systemctl enable ntp
配置client
sudo vimd /etc/ntp.conf# 本地server IP地址
server 192.168.0.118
命令行同步时间
ntpd -c /etc/ntp.conf -gdq