当前位置:首页 > linux > 正文

linux ntp配置命令(linux ntp开启的命令)

  • linux
  • 2024-03-15 20:54:30
  • 6422
ntpd 配置命令
ntpd 是 Linux 系统中用于网络时间协议 (NTP) 的守护进程。 以下为其配置命令:
命令:
/etc/ntp.conf
配置要素:

1. 全球时间服务器
server <名称>:指定全球时间服务器。
例如:server ntp.ubuntu.com

2. 本地时区
zone <区域>:设置本地时区。
例如:zone "US/Eastern"

3. 偏移量
driftfile <文件>:指定包含时间偏移量的文件。
例如:driftfile /var/lib/ntp/ntp.drift

4. 对等方
peer <地址>:指定其他 NTP 服务器作为对等方。
例如:peer 192.168.1.1

5. 认证
keys <文件>:指定包含用于认证的密钥的文件。
例如:keys /etc/ntp/ntp.keys

6. 限制访问
restrict <地址>:限制对 NTP 服务器的访问。
例如:restrict default ignore

7. 默认统计数据
statistics loopstats:启用循环统计数据。
例如:statistics loopstats
示例配置:
# /etc/ntp.conf
# 全球时间服务器
server ntp.ubuntu.com
# 本地时区
zone "US/Eastern"
# 时钟偏移量
driftfile /var/lib/ntp/ntp.drift
# 认证
keys /etc/ntp/ntp.keys
# 限制访问
restrict default ignore
restrict 127.0.0.1
restrict ::1
# 默认统计数据
statistics loopstats