一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Linux - linux配置ntp服務器的方法

linux配置ntp服務器的方法

2021-12-09 15:47Linux教程網 Linux

下面小編就為大家帶來一篇linux配置ntp服務器的方法。小編覺得挺不錯的,現在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

linux配置ntp服務器的方法

一.安裝ntp軟件

1.檢查是否安裝了ntp相關包。
rpm -qa | grep ntp

2.安裝ntp軟件。
yum -y install ntp

二.參數講解

ignore  :關閉所有的 NTP 聯機服務

nomodify:客戶端不能更改服務端的時間參數,但是客戶端可以通過服務端進行網絡校時。

notrust :客戶端除非通過認證,否則該客戶端來源將被視為不信任子網

noquery :不提供客戶端的時間查詢:用戶端不能使用ntpq,ntpc等命令來查詢ntp服務器

notrap :不提供trap遠端登陸:拒絕為匹配的主機提供模式 6 控制消息陷阱服務。陷阱服務是 ntpdq 控制消息協議的子系統,用于遠程事件日志記錄程序。

nopeer :用于阻止主機嘗試與服務器對等,并允許欺詐性服務器控制時鐘

kod : 訪問違規時發送 KoD 包。

三.修改配置文件

1.查看未修改的配置文件

?
1
2
3
4
5
6
7
8
9
10
11
12
# grep ^[^#] /etc/ntp.conf 
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

1.設置允許任何IP的客戶機都可以進行時間同步(修改后的配置文件)

?
1
2
3
4
5
6
7
8
9
10
11
12
# grep ^[^#] /etc/ntp.conf 
driftfile /var/lib/ntp/drift
restrict default nomodify notrap
restrict 127.0.0.1
restrict ::1
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

2.只允許192.168.1.0網段的客戶機進行時間同步(修改后的配置文件)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
# grep ^[^#] /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.ntp.org iburst
server 3.centos.pool.ntp.org iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

四.啟動NTP服務和防火墻

systemctl start ntpd
systemctl enable ntpd
iptables -A INPUT -p UDP -i eno16777736 -s 192.168.1.0/24 --dport 123 -j ACCEPT
setsebool -P ntp_disable_trans 1#SELinux設置
vi /etc/sysconfig/ntpd#允許BIOS與系統時間同步,添加下面一行。
SYNC_HWCLOCK=yes

五.檢測NTP

1.檢測NTP服務是否運行

?
1
2
3
4
5
6
7
# netstat -tlunp | grep ntp
udp    0   0 192.168.1.101:123    0.0.0.0:*              2563/ntpd    
udp    0   0 127.0.0.1:123      0.0.0.0:*              2563/ntpd    
udp    0   0 0.0.0.0:123       0.0.0.0:*              2563/ntpd    
udp6    0   0 fe80::20c:29ff:fe7b:123 :::*                2563/ntpd    
udp6    0   0 ::1:123         :::*                2563/ntpd    
udp6    0   0 :::123         :::*                2563/ntpd

2.查看ntp服務器有無和上層ntp連通

?
1
2
3
4
# ntpstat
synchronised to NTP server (120.25.108.11) at stratum 3
  time correct to within 99 ms
  polling server every 64 s

3.查看ntp服務器與上層ntp的狀態

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# ntpq -p
   remote      refid   st t when poll reach  delay  offset jitter
==============================================================================
 news.neu.edu.cn .INIT.     16 u  -  64  0  0.000  0.000  0.000
x202.118.1.130  202.118.1.47   2 u  7  64 377 153.659  9.605 19.941
*time4.aliyun.co 10.137.38.86   2 u  10  64 377  39.666 -47.661 15.944
remote  - 本機和上層ntp的ip或主機名,“+”表示優先,“*”表示次優先
refid  - 參考上一層ntp主機地址
st    - stratum階層
when   - 多少秒前曾經同步過時間
poll   - 下次更新在多少秒后
reach  - 已經向上層ntp服務器要求更新的次數
delay  - 網絡延遲
offset  - 時間補償
jitter  - 系統時間與bios時間差

六.配置時間同步客戶機

1.執行ntpdate命令:

ntpdate 192.168.1.101 #192.168.1.101為ntp服務器IP地址

2.寫入BIOS

hclock -w

3.crond服務

vi /etc/crontab
30 8 * * * root /usr/sbin/ntpdate 192.168.1.101; /sbin/hwclock -w

4.重啟crond服務

service crond restart

以上就是小編為大家帶來的linux配置ntp服務器的方法全部內容了,希望大家多多支持服務器之家~

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产欧美亚洲精品第一页青草 | 国产精品成人在线播放 | 欧美亚洲免费 | 国产亚洲欧美日韩综合综合二区 | 奇米影视亚洲狠狠色 | 青草欧美 | 国产毛片一级aaaaa片 | 国产在线伊人 | 五月色婷婷网在线观看 | 色帽子影院| 女明星放荡高h日常生活 | 国产亚洲福利一区二区免费看 | 日本欧美不卡一区二区三区在线 | 美女黄板视频 | 俄罗斯一级大片 | 国产免费午夜高清 | 亚洲 欧美 中文 日韩欧美 | 国产久视频 | 色哟约| 91精品免费观看老司机 | 国产成人咱精品视频免费网站 | 夫承子液by免费阅读 | 99久久中文字幕伊人 | 亚洲成人伦理 | 久久精品99国产精品日本 | 福利视频一区二区三区 | 水多多www视频在线观看高清 | 久久亚洲一级α片 | 国产精品麻豆免费版 | 亚洲日本va午夜中文字幕 | 亚洲高清在线天堂精品 | 999国产精品亚洲77777 | 日比免费视频 | 60岁了天天要小伙子 | 第一福利在线导航 | 天天天综合网 | 欧洲老妇人70| 亚欧日韩 | 热热影院 | 国内精品91东航翘臀女神在线 | 亚洲国产欧美在线人成 |