温馨提示×

ntp服务器搭建怎么配置

小亿
139
2023-06-19 12:38:51
栏目: 云计算

搭建 NTP 服务器需要以下步骤:

  1. 安装 NTP 软件

使用以下命令安装 NTP 软件:

sudo apt-get update
sudo apt-get install ntp
  1. 修改 NTP 配置文件

使用以下命令编辑 NTP 配置文件:

sudo nano /etc/ntp.conf

在文件中添加以下内容:

# You do need to talk to an NTP server or two (or three).
server ntp.ubuntu.com
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org

这里使用了 Ubuntu 官方的 NTP 服务器。你也可以使用其他 NTP 服务器。

  1. 重启 NTP 服务

使用以下命令重启 NTP 服务:

sudo service ntp restart
  1. 配置防火墙

如果你的服务器开启了防火墙,需要打开 UDP 123 端口。使用以下命令打开端口:

sudo ufw allow 123/udp

现在你的 NTP 服务器已经搭建成功了。其他设备可以使用该服务器进行时间同步。

0