# 安装 NTP 服务
sudo apt-get update
sudo apt-get install ntp
# 编辑 NTP 配置文件
sudo nano /etc/ntp.conf
# 在配置文件中添加或修改以下内容:
# 指定上游 NTP 服务器
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org
# 允许本地网络中的设备同步时间
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# 保存并退出编辑器 (Ctrl+X, 然后按 Y, 最后按 Enter)
# 重启 NTP 服务以应用更改
sudo systemctl restart ntp
# 检查 NTP 服务状态
sudo systemctl status ntp
# 查看 NTP 同步状态
ntpq -p
apt-get 命令来更新软件包列表并安装 NTP 服务。nano 编辑 /etc/ntp.conf 文件,指定上游 NTP 服务器,并设置访问控制规则。server 指令添加多个公共 NTP 服务器,确保时间同步的可靠性和冗余性。restrict 指令设置访问控制规则,允许特定 IP 地址范围内的设备同步时间。systemctl 命令重启 NTP 服务以应用配置文件中的更改。systemctl status 命令查看 NTP 服务的运行状态。ntpq -p 命令查看当前 NTP 同步状态,确认时间同步是否正常工作。上一篇:linux磁盘总容量命令
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站