时间同步服务

时间同步服务

一、 ntpd服务

[root@dns-server ~]# vim /etc/ntp.conf 
 restrict 192.168.221.0 mask 255.255.255.0 nomodify notrap
//允许192.168.221.0/24网段的主机同步时间

[root@dns-server ~]# service ntpd start
Starting ntpd:                                             [  OK  ]
[root@dns-server ~]# netstat -ntplu |grep ntpd
udp        0      0 192.168.221.129:123         0.0.0.0:*                               1741/ntpd           
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1741/ntpd           
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1741/ntpd           
udp        0      0 fe80::20c:29ff:feb0:149d:123 :::*                                    1741/ntpd           
udp        0      0 ::1:123                     :::*                                    1741/ntpd           
udp        0      0 :::123                      :::*                                    1741/ntpd           

客户端同步:
[root@dns-client ~]# ntpdate 192.168.221.129
24 Jun 18:43:13 ntpdate[1645]: adjust time server 192.168.221.129 offset 0.004234 sec
//这种方法依赖于外网

二、托管于xinetd的时间同步

[root@dns-server ~]# vim /etc/xinetd.d/time-dgram
  3 service time
  4 {
  5 # This is for quick on or off of the service
  6         disable         = no
  7 

[root@dns-server ~]# vim /etc/xinetd.d/time-stream
  3 service time
  4 {
  5 # This is for quick on or off of the service
  6         disable         = no

[root@dns-server ~]# service xinetd restart
Stopping xinetd:                                           [  OK  ]
Starting xinetd:                                           [  OK  ]
[root@dns-server ~]# netstat -ntplu |grep 37
tcp        0      0 :::37                       :::*                        LISTEN      1837/xinetd

//客户端同步时间
[root@server ~]# date
Sun Jun 24 00:10:52 CST 2018
[root@server ~]# rdate -s 192.168.221.129
[root@server ~]# date
Sun Jun 24 19:05:30 CST 2018
//同步成功

注:

​ ①ntpd服务同步时间,要在配置文件中允许其他机器同步才行,客户端用ntpdate IP同步。

​ ②xinetd的时间同步服务,需修改其子配置文件将time-dgram 和time-stream中的disabled选项改为no。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值