RHCSA作业2
通过自定义时间服务器向指定的客户端主机同步时间
要求:自定义时间服务器主机的时间通过ntp.aliyun.com主机同步时间
服务端主机:192.168.227.135
(1) 环境准备
- 客户端和服务端正常建立网络连接 (同一种网络模式)
- 连接外网 NAT
[root@server ~]# ping ntp.aliyun.com
PING ntp.aliyun.com (203.107.6.88) 56(84) bytes of data.
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=1 ttl=128 time=46.6 ms
64 bytes from 203.107.6.88 (203.107.6.88): icmp_seq=2 ttl=128 time=56.1 ms
^C
--- ntp.aliyun.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5005ms
rtt min/avg/max/mdev = 46.589/63.160/77.111/11.543 ms
- 关闭防火墙,关闭selinux
[root@server ~]# systemctl stop firewalled
[root@server ~]# setenforce 0
(2) 判断是否有软件包
[root@server ~]# rpm -qa | grep chrony
chrony-4.2-1.el9.x86_64
[root@server ~]# ps -aux | grep chronyd
chrony 2794 0.0 0.1 84108 2560 ? S 20:35 0:00 /usr/sbin/chronyd -F 2
root 2839 0.0 0.1 221664 2276 pts/0 S+ 21:03 0:00 grep --color=auto chronyd
(3) 服务程序的设置(/etc/chrony.conf)
[root@server ~]# vim /etc/chrony.conf#注释掉原rhel,将aliyun写入
#pool 2.rhel.pool.ntp.org iburst
pool ntp.aliyun.com iburst# 允许 客户端主机的网段或者ip/24
allow 192.168.227.136/24
#本地服务主机的等级 10
local stratum 10
注:取消#注释
(4) 重启软件程序(服务)
[root@server ~]# systemctl restart chronyd
(5) 查看
[root@server ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 203.107.6.88 2 6 37 22 -45us[-6078us] +/- 29ms
客户端主机:192.168.227.136
(1) 环境准备
客户端和服务端正常建立网络连接
(2) 服务程序的设置
#pool 服务器主机的ip或者域名 iburst
pool 192.168.227.135 iburst
(3) 启动软件读取配置(发起时间同步请求)
[root@client ~]# systemctl restart chronyd
(4) 查看
[root@client ~]# chronyc sources
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.227.136 3 6 7 1 +2440ns[+3277us] +/- 36ms
* 表示正在匹配链接的服务器主机