ubuntu 配置NTP时间服务器

sudo apt update
显示秒(进入Top Bar 打开second)
sudo apt install gnome-tweaks
安装ntp服务器
sudo apt install ntp
在服务端修改ntp配置开放客户端所在的网段
sudo gedit /etc/ntp.conf
restrict 172.19.7.0 mask 255.255.255.0 nomodify notrap
重启查看服务
sudo systemctl restart ntp
sudo systemctl status ntp
开放端口(一般情况下可省略)
sudo ufw allow 123/udp
验证是否成功
sudo apt install tcpdump
sudo tcpdump -i enp3s0f0 port 123
在客户端上进行手动ntp操作
sudo apt install ntpdate
sudo ntpdate [NTP-server-host'IP]


其他常用命令
1.修改时间
sudo date 091614302023
2.查看时间状态
timedatectl
3.安装ntpd查看服务器与上游服务器状态(客户端也可用)
sudo apt install ntpdate
ntpq -p
4.小tips
NTP服务与systemd-timesyncd:
在较新的Ubuntu版本中,systemd-timesyncd 是默认的简易NTP客户端。它是由 systemd 提供的,用于同步系统时钟。使用 timedatectl 查询状态时,它实际上查看的是 systemd-timesyncd 的状态,而不是传统的NTP服务。如果你安装并启动了传统的NTP服务(如 ntp 或 ntpd),systemd-timesyncd 通常会被自动禁用,因为两者不应该在同一台机器上同时运行。这可能是 timedatectl 显示 "NTP service: no" 的原因,因为它不再使用 systemd-timesyncd








 Client 代表 客户端ntp请求服务端

Server 代表 服务端ntp回应服务端

端口:123

网卡:ens33

猜你喜欢

转载自blog.csdn.net/qq_42314865/article/details/132919182