linux时间同步ntp和rdate

一 、 ntpdate工具和ntp服务

ntp服务,走的是udp协议,默认端口为123。

安装

#yum install ntp -y

设置

#vim /etc/ntp.conf

添加和修改:

restrict 192.168.11.0 mask 255.255.255.0 notrust nomodify notrap
server 0.centos.pool.ntp.org iburst

server的地址可以改成国内的某个时间服务器的地址

启动:

#service ntpd start
#chkconfig ntpd on
#chkconfig ntpd --list

防火墙:

iptables -I INPUT 4 -p tcp --dport 123 -j ACCEPT
iptables -I INPUT 4 -p udp --dport 123 -j ACCEPT
iptables -I INPUT 4 -p tcp --sport 123 -j ACCEPT
iptables -I INPUT 4 -p udp --sport 123 -j ACCEPT

iptables -A OUTPUT -p tcp --sport 123 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 123 -j ACCEPT
iptables -A OUTPUT -p udp --sport 123 -j ACCEPT
iptables -A OUTPUT -p udp --dport 123 -j ACCEPT

service iptables status

#根据自己需求来

使用:

#ntpdate 192.168.11.201

 

 

二 、rdate工具和time服务

​​​​​​​(time-dgram和time-stream,分别是upd和tcp协议的time服务)
time服务有2种分别是udp和tcp协议,默认端口37。

 安装:

#yum install xinetd -y

 设置:

vim /etc/xinetd.d/time-stream 
vim /etc/xinetd.d/time-dgram
把默认的disable = yes改为disable = no

启动:

#service xinetd start
#telnet 127.0.0.1 37

防火墙:

#iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 37 -j ACCEPT
#iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --sport 37 -j ACCEPT
#service iptables status
#service iptables save

使用:

#rdate -s 192.168.11.221

 

转载于:https://my.oschina.net/lenglingx/blog/1560830

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值