Skip to the content.

Cài đặt NTP server trên Centos 7.

NTP(Network Time Protocol) là giao thức giúp đồng bộ thời gian qua mạng, sử dụng port 123/udp.

Cài đặt ntp server:

1. Cài đặt và cấu hình NTP daemon.

Use public servers from the pool.ntp.org project.

Please consider joining the pool (http://www.pool.ntp.org/join.html).

#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 server 0.asia.pool.ntp.org iburst server 1.asia.pool.ntp.org iburst server 2.asia.pool.ntp.org iburst server 3.asia.pool.ntp.org iburst

- Thêm cấu hình sau vào cuôi  file nếu muốn lưu log:

logfile /var/log/ntp.log


![](https://i.imgur.com/pWcSudg.png)

### 2. Cấu hình firewall và chạy dịch vụ NTP.
- Cấu hình firewalld thêm dịch vụ ntp để mở port 123/UDP trên server:

firewall-cmd –add-service=ntp –permanent firewall-cmd –reload

- Chạy và cấu hình enable `ntpd`:

systemctl start ntpd systemctl enable ntpd systemctl status ntpd


### 3. Xác nhận 
- Kiểm tra trạng thái các server NTP:

ntpq -p

[root@cen ~]# ntpq -p remote refid st t when poll reach delay offset jitter ============================================================================== *crimson.en.kku. .PPS. 1 u 52 64 177 83.070 6.168 21.678 +ntp.kku.ac.th .PPS. 1 u 53 64 177 88.591 -7.054 32.292 +send.mx.cdnetwo 216.239.35.8 2 u 58 64 177 63.082 16.822 16.117 -time1.isu.net.s 216.218.192.202 2 u 58 64 177 345.941 58.597 36.603

- Kiểm tra ngày giờ theo chuẩn RFC 2822:

[root@cen ~]# date -R Fri, 26 Jul 2019 10:04:58 +0700


### Cấu hình trên NTP client 
Cài đặt NTP Daemon:

yum install -y ntp


Cấu hình file /etc/ntp.conf để đồng bộ ntp qua server( 10.88.88.143).

Use public servers from the pool.ntp.org project.

Please consider joining the pool (http://www.pool.ntp.org/join.html).

#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

server 10.88.88.143 iburst

- Để kiểm tra, chạy lệnh:

ntpq -p ```