微网站和普通网站区别,免费建手机网站,有多个网页的大网站如何做,金华建设网Ubuntu离线安装ntp服务
准备阶段#xff1a;下载安装包 apt-get download ntp apt-get download ntpdate
一、服务端( 192.166.6.xx) 1、环境准备 先判断是否已安装 systemd-timesyncd systemctl is-active systemd-timesyncd 如果返回结果是 active#xff0c;则表示…Ubuntu离线安装ntp服务
准备阶段下载安装包 apt-get download ntp apt-get download ntpdate
一、服务端( 192.166.6.xx) 1、环境准备 先判断是否已安装 systemd-timesyncd systemctl is-active systemd-timesyncd 如果返回结果是 active则表示 systemd-timesyncd 已经在运行。在这种情况下你可以使用以下命令停止并卸载它 sudo systemctl stop systemd-timesyncd sudo systemctl disable systemd-timesyncd sudo apt-get remove systemd-timesyncd 如果返回inactive则表示 systemd-timesyncd没有在运行可直接安装ntp 2、安装 sudo dpkg -i ntp包 sudo dpkg -i ntpdate包
2、编辑配置文件/etc/ntp.conf
# /etc/ntp.conf, NTP服务配置文件
# 指定 drift 文件的位置它用于存储系统时钟的漂移信息
driftfile /var/lib/ntp/ntp.drift
# 指定闰秒的定义文件
leapfile /usr/share/zoneinfo/leap-seconds.list
# 启用统计数据记录以便进行性能监控
statistics loopstats peerstats clockstats
# 定义日志文件的生成可以在文件中存储不同类型的统计信息
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
# 配置本地系统的时钟作为 NTP 时间服务器
# 127.127.1.0 表示本地时钟 每16秒向本地时钟服务器发出一次查询
server 127.127.1.0 minpoll 4 maxpoll 4
# 设置本地时钟的层级stratum 值表示时间源的等级
# stratum 0 是最高等级通常不应该更改
fudge 127.127.1.0 stratum 5
# 使用 Ubuntu 提供的 NTP 服务器作为备用时间源
#pool ntp.ubuntu.com
# 限制外部访问不允许未授权的操作
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited
# 允许本地主机 127.0.0.1 访问 NTP 服务
restrict 127.0.0.1
# 允许 IPv6 本地主机 ::1 访问 NTP 服务
restrict ::1
# 不允许外部主机修改或请求服务器的状态信息
restrict source notrap nomodify noquery3、重启 service ntp restart
二、客户端(192.168.228.xx) 1、环境准备 先判断是否已安装 systemd-timesyncd systemctl is-active systemd-timesyncd 如果返回结果是 active则表示 systemd-timesyncd 已经在运行。在这种情况下你可以使用以下命令停止并卸载它 sudo systemctl stop systemd-timesyncd sudo systemctl disable systemd-timesyncd sudo apt-get remove systemd-timesyncd 如果返回inactive则表示 systemd-timesyncd没有在运行可直接安装ntp 2、安装 sudo dpkg -i ntp包 sudo dpkg -i ntpdate包
3、编辑配置文件/etc/ntp.conf
# 指定 drift 文件的位置用于存储系统时钟漂移信息
driftfile /var/lib/ntp/drift# 针对默认配置限制 NTP 服务的访问权限阻止外部修改服务器状态
restrict default kod limited nomodify notrap nopeer noquery
# 允许本地主机 127.0.0.1 访问 NTP 服务
restrict 127.0.0.1
# 允许 IPv6 本地主机 ::1 访问 NTP 服务
restrict ::1
# 限制特定 IP 地址 192.166.6.47 访问但不允许修改或请求服务器状态
restrict 192.166.6.47 nomodify notrap noquery
# 配置 NTP 服务器的地址
server 192.166.6.47
# 包含文件通常用于加密配置信息
includefile /etc/ntp/crypto/pw
# 指定 NTP 密钥文件的位置
keys /etc/ntp/keys
# 禁用监视器功能
disable monitor
4、重启 service ntp restart 5、手动更新系统的时钟 ntpdate -d 192.166.6.xx