본문 바로가기

Linux/구축 관련

CentOS에서 NTP 서버 구축하기 (타임서버)




CentOS에서 NTP 서버 구축하기






공통


CentOS 6.8에서 구축

Server : 192.168.0.127

Client : 192.168.0.124


##NTP 관련 패키지 설치 여부 확인

[root@localhost ~]# rpm -qa | grep ntp


##NTP 관련 패키지 설치

[root@localhost ~]# yum -y install ntp


설정(Server)


[root@localhost ~]# vi /etc/ntp.conf

# Hosts on local network are less restricted.

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap

## 위 내용 추가 192.168.0.대역의 IP NTP 허용


# 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 127.127.1.0    #local clock
## 윗 부분을 주석처리하여 시간 정보를 받아오지 않도록 한다.

[root@localhost ~]# service ntpd start
[root@localhost ~]# chkconfig ntpd on
[root@localhost ~]# chkconfig --list ntpd
ntpd            0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제


설정(Client)


[root@localhost ~]#

# 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 192.168.0.127
시간정보를 가져올 Server 쪽을 추가시켜주고 나머지 기본으로 들어가있는 것들은 주석처리하여 받아오지 않도록 처리
[root@localhost ~]# chkconfig ntpd on
[root@localhost ~]# chkconfig --list ntpd
ntpd            0:해제  1:해제  2:활성  3:활성  4:활성  5:활성  6:해제


명령어


##Server에서 확인

[root@localhost ~]# ntpq -pn

     remote           refid      st t when poll reach   delay   offset  jitte           r

==============================================================================

*127.127.1.0     .LOCL.           5 l   51   64   17    0.000    0.000   0.00           0



##Client에서 확인
[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*192.168.0.127   LOCAL(0)         6 u   55   64  177    0.200    0.463   0.257


##Client에서 수동으로 동기화
[root@localhost ~]# ntpdate 192.168.0.127

##OS 시간을 CMOS 시간으로 변경
[root@localhost ~]# clock -w

##원하는 시간으로 변경
[root@localhost ~]# date -s 시:분:초

##현재 시간 확인
[root@localhost ~]# date

##외부 시간과 동기화(time.bora.net)
[root@localhost ~]# rdate -s time.bora.net


우선순위


[root@localhost ~]# vi /etc/ntp.conf

...

restrict default kod nomodify notrap nopeer noquery

restrict 127.0.0.1

# local clock

server 127.127.1.0

fudge 127.127.1.0 stratum 10


127.127.1.0 이 localtime이고 stratum이 우선 순위이다. 낮을 수록 우선하게 되는데 10을 줌으로써 localtime의 우선순위를 낮춘다.


혹은


[root@localhost ~]# vi /etc/ntp.conf

/etc/ntp.conf

...

server 192.168.0.127 prefer


prefer 옵션을 주면 기준이 된다.




'Linux > 구축 관련' 카테고리의 다른 글

CentOS 환경에서 DNS 구축  (0) 2016.12.15
리눅스에서 GUI 환경으로 원격제어 (VNC)  (0) 2016.12.15
CentOS에서 USB 사용하기 (FAT32, NTFS)  (0) 2016.11.30
Eclipse 설치  (0) 2016.11.18
JDK, JRE (JAVA) 설치  (0) 2016.11.18