Ntp时间同步服务器

下面内容根据实际情况修改
time.windows.com 时间服务器地址
服务器A 192.168.7.9 时间同步服务器(能通外网)
服务器B 192.168.7.8 内网服务器

服务器A

安装依赖

yum -y install ntp ntpdate
systemctl daemon-reload && systemctl start ntpd && systemctl enable ntpd
  • 修改配置文件(参考一下内容):vim /etc/ntp.conf
driftfile /var/lib/ntp/drift

restrict default nomodify notrap nopeer noquery

restrict 192.168.7.9 
restrict ::1
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap

server 127.127.1.0
fudge 127.127.1.0 stratum 10

includefile /etc/ntp/crypto/pw

keys /etc/ntp/keys

disable monitor
  • 设置开机自启
systemctl daemon-reload && systemctl restart ntpd && systemctl enable ntpdate
  • 同步时间服务器时间
ntpdate time.windows.com
  • 定时任务(每10分钟执行一次)
echo "*/10 * * * * /usr/sbin/ntpdate -u time.windows.com > /dev/null 2>&1" >> /var/spool/cron/root
crontab -l
  • 开启防火墙端口
firewall-cmd --zone=public --add-port=123/udp --permanent
firewall-cmd --list-ports --permanent

服务器B

安装依赖

yum -y install ntpdate
  • 手动同步服务器A
ntpdate 192.168.7.8
  • 定时任务(每10分钟执行一次)
echo "*/10 * * * * /usr/sbin/ntpdate 192.168.7.8 > /dev/null 2>&1" >> /var/spool/cron/root
crontab -l
  • 端口转发(可以不执行)
iptables -t nat -I OUTPUT -p udp -d 173.0.255.52 --dport 123 -j DNAT --to 173.0.255.52:12345
ntpdate 173.0.255.52
  • 6
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值