쭈꾸댕이 2008. 12. 8. 13:04

/etc/ntp.conf를 수정한다.
# vi /etc/ntp.conf

ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.

restrict default nomodify notrap noquery
# restrict default kod nomodify notrap nopeer noquery
# restrict -6 default kod nomodify notrap nopeer noquery

# Permit all access over the loopback interface.  This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
# restrict -6 ::1

# Hosts on local network are less restricted.
restrict 150.183.0.0 mask 255.255.0.0 nomodify notrap
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (
http://www.pool.ntp.org/join.html).
server 210.98.16.100
server 210.98.16.101
# server 1.rhel.pool.ntp.org
# server 2.rhel.pool.ntp.org

#broadcast 192.168.1.255 key 42         # broadcast server
#broadcastclient                        # broadcast client
#broadcast 224.0.1.1 key 42             # multicast server
#multicastclient 224.0.1.1              # multicast client
#manycastserver 239.255.254.254         # manycast server
#manycastclient 239.255.254.254 key 42  # manycast client

# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

# Drift file.  Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift

# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys

# Specify the key identifiers which are trusted.
#trustedkey 4 8 42

# Specify the key identifier to use with the ntpdc utility.
#requestkey 8

# Specify the key identifier to use with the ntpq utility.
#controlkey 8


/etc/ntp.conf 와 driftfile 과 keys의 경우 배포본마다 위치가 다를 수 있으니 확인 하도록 한다. (find / -name ntp.conf)
restric 설정은 peer 들이 본 서버로 sync 하는 것에 대한 제한을 한다.

restrict default nomodify notrap noquery // 이 설정은 기본으로 모든 권한을 주지 않음을 의미한다.

restrict 127.0.0.1 // 127.0.0.1 즉, 서버 자신에서는 모든 권한을 가진다.

restrict 150.183.0.0 mask 255.255.0.0 nomodify notrap // 150.183.0.0 ~ 150.183.0.255 c class 에서는 질의를 할 수 있는 권한을 가진다.

즉, 위의 2개의 설정은 기본으로 들어가는 설정이며, peer를 거느릴 서버에서는(즉 A의 입장) 하위 peer 들의 질의를 받을 수 있도록 3번째 라인과 같이 restrict 설정을 해주어야 한다.

설정을 마쳤다면 service ntpd restart 명령으로 ntpd를 시작하고, ntpd 명령을 이용하여 sync 를 잘 하고 있는지 확인한다.


실행 예)
[root@ntp ~]# service ntpd start
Starting ntpd: [  OK  ]
[root@ntp ~]#

[root@ntp ~]# service ntpd restart
Shutting down ntpd: [  OK  ]
Starting ntpd: [  OK  ]
[root@ntp ~]#

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

[root@ntp ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 210.98.16.100   .INIT.          16 u    -   64    0    0.000    0.000   0.000
 210.98.16.101   .INIT.          16 u    -   64    0    0.000    0.000   0.000
 LOCAL(0)        .LOCL.          10 l    -   64    1    0.000    0.000   0.001
[root@ntp ~]#


ntpd를 막 재시작하고 ntpq를 실행한 경우 5분 정도를 기다려야 sync가 진행이 된다는 것을 명심한다. (그러나 필자의 경우 1분도 안 걸림 ^^ )

server 127.127.1.0 // 현재 서버가 타임서버 루트가 되도록 할 시 이와같이 설정한다.


remote는 sync를 하는 Straum 2 서버 주소이다.
refid는 각 Straum 2 서버가 현재 sync를 하고 있는 Straum 1 서버를 보여준다.
st는 각 라인의 remote들의 Straum을 나타낸다.

그 외의 항목들은 ntp가 알아서 하는 것들이니 신경쓰지 말고, 가장 중요한 것은 remote 필드의 주소 앞에 붙어 있는 기호이다.
각 기호의 의미는 아래와 같다.
* 는 현재 sync를 받고 있음을 의미한다.
+ ntp 알고리즘에 의해 접속은 가능하지만 sync를 하고 있지는 않는 것을 의미한다.
- ntp 알고르짐에 의해 접속은 가능하지만 sync 가능 리스트에서 제외
blank는 접속이 불가능함을 의미한다.
마지막으로 st가 16이 나올 경우는 해당 서버에 접속을 할 수 없는 것을 의미한다.