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.confspa

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.net

 

# 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.confrest

# 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  code

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

 

經常使用的Ntp服務器:server

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.comblog

相關文章
相關標籤/搜索