FreeBSD NTP 简单使用

FreeBSD NTP 简单使用

来源 https://blog.csdn.net/stevexk/article/details/1349506

1.ntptrace xxx.xxx.xxx.xxx
查找要对时的服务器状态,可以trace到一级时钟服务器,
2.ntpq -p 或者 ntpq -pn
显示当前时钟服务器状态
3.ntpdata xxx.xxx.xxx.xxx  或者 ntpdata -d xxx.xxx.xxx.xxx (Debug模式)
与时钟服务器对时,着先时钟服务器要先对时,才能用来提钟时钟服务
4.ntpd
既可以自动对时,又可对外提供时钟服务,先要配置/etc/ntp.conf

restrict 0.0.0.0 mask 0.0.0.0 notrust nomodify notrap //控制访问
server xxx.xxx.xxx.xxx  //对时的外部服务器
server 127.127.1.0  
fudge 127.127.1.0 stratum 10
driftfile /etc/ntpd.drift


5.开机对时,/etc/rc.conf中添加
 ntpdate_enable="YES" 
 ntpdate_program="/usr/sbin/ntpdate"
 ntpdate_flags="-b"

6.每天(好像是每天)对时且对外提供时钟服务,  在/etc/rc.conf中添加

 xntpd_enable="YES"
 xntpd_program="/usr/sbin/ntpd"
 xntpd_flags="-p /var/run/ntpd.pid"

7.端口
 时钟服务器端口为123,udp , netstat  -an

 

# We won't allow *anything* from hosts not listed in the configuration
# This means you need a restrict line for each server
restrict default ignore
restrict -6 default ignore

# Allow just about anything from localhost, IPv4. 
restrict 127.0.0.1 mask 255.0.0.0 

restrict 127.0.0.1
restrict -6 ::1

driftfile /var/tmp/ntp.drift
logfile /var/log/ntpd.log

# Log everything, even from ntpd (which otherwise defaults to "all =sync")
logconfig =all +all

server 127.127.1.0
fudge 127.127.1.0 stratum 5

server 182.92.12.11 minpoll 6 maxpoll 10 
restrict 182.92.12.11 nomodify notrap nopeer noquery

 

/etc/ntp.common.conf

# Common elements of NTP configuration
#
# Do not edit: changes will be lost following reboot. 
# For site-specific NTP configuration, see the instructions in /etc/ntp.conf
#

# We won't allow *anything* from hosts not listed in the configuration
# This means you need a restrict line for each server
restrict default ignore
restrict -6 default ignore

# Allow just about anything from localhost, IPv4. 
restrict 127.0.0.1 mask 255.0.0.0 

restrict 127.0.0.1
restrict -6 ::1

driftfile /var/tmp/ntp.drift
logfile /var/log/ntpd.log

# Log everything, even from ntpd (which otherwise defaults to "all =sync")
logconfig =all +all

server 127.127.1.0
fudge 127.127.1.0 stratum 5

 

/etc/ntp.conf  

includefile /etc/ntp.common.conf
server 218.75.4.130 minpoll 6 maxpoll 10 
restrict 218.75.4.130 nomodify notrap nopeer noquery

 

常用的Ntp服务器:

203.107.6.88
ntp.aliyun.com
ntp1.aliyun.com
ntp2.aliyun.com
ntp3.aliyun.com
ntp4.aliyun.com
ntp5.aliyun.com
ntp6.aliyun.com
ntp7.aliyun.com
ntp8.aliyun.com

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值