首先下载ntp
sudo apt install ntp
修改配置文件
sudo vim /etc/ntp.conf
加粗的文字要注释掉
# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
# Use Ubuntu's ntp server as a fallback.
#pool ntp.ubuntu.com
不注释掉之前 sudo service ntp status 得到如下,是不能作为ntp的服务端的。
这里添加的分别是 本机ip 网关 和掩码
restrict 192.168.1.22 nomodify notrap nopeer noquery
restrict 192.168.1.1 mask 255.255.255.0 nomodify notrap
最后添加
server 127.127.1.0
fudge 127.127.1.0 stratum 10
全部完成之后
sudo service ntp stop
sudo service ntp start
sudo service ntp status (查看状态)
完成。
参考链接