ntp服务器配置

📅 2026/7/13 19:02:39 👁️ 阅读次数 📝 编程学习
ntp服务器配置

一、ubuntu 20配置

1、安装 NTP 服务器安装包

apt-get install -y ntp

2、编辑配置文件

修改配置文件/etc/ntp.conf,修改以下内容:

restict 192.168.8.1 mask 255.255.255.0 modify notrap server 127.127.1.0 fudge 127.127.1.0 stratum 10

3、启动NTP服务并设置为开机自启

sudo systemctl start ntp sudo systemctl enable ntp

4、检查NTP服务状态和时间同步

sudo systemctl status ntp ntpq -p

5、离线安装ntp

首先将离线安装包deb传输到离线机器

然后将离线包解压到目标文件夹

tar -xzvf /path/to/destination/ntp-offline.tar.gz -C /path/to/destination

在离线机器上,进入解压目录并使用dpkg安装所有.deb

cd /path/to/destination/ntp sudo dpkg -i *.deb

如果安装过程中提示缺少依赖,可以尝试以下命令修复依赖:

sudo apt-get install -f

二、ubuntu24配置

1、清理冲突,使用aptitude安装

sudo apt install aptitude sudo aptitude install ntp

2、配置,创建/etc/ntp.conf

server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org server 3.ubuntu.pool.ntp.org server ntp.aliyun.com iburst server ntp1.aliyun.com iburst server ntp2.aliyun.com iburst server ntp.tuna.tsinghua.edu.cn iburst server 127.127.1.0 fudge 127.127.1.0 stratum 10