서버의 시간이 조금만 어긋나도 인증서 검증, 분산 로그 정렬, 토큰 유효기간 판단에 문제가 생길 수 있다. Ubuntu에서 NTP 관련 서비스가 active라고 표시되더라도 실제 시계가 올바른 시간 소스와 동기화됐다는 뜻은 아니다.

이 실습에서는 Ubuntu 24.04의 systemd-timesyncd와 Chrony를 비교하며 어떤 서버에서 시간을 받아오는지, 실제 오차가 얼마나 되는지, 동기화가 지속되고 있는지를 구분해서 확인한다.

1. 두 구현의 역할과 선택 기준

항목systemd-timesyncdChrony
중심 역할간단한 SNTP 클라이언트NTP 클라이언트·서버와 다양한 시간 소스 관리
상태 확인timedatectl과 systemd 로그chronyc tracking·sources와 서비스 로그
검토할 요구간단한 클라이언트 동기화시간 서버 제공·간헐 연결·세밀한 소스 선택 등

Chrony를 설치한다고 모든 환경에서 고정된 μs 정확도를 보장하지 않는다. timesyncd 역시 “현재 오차만 즉시 맞추고 어떤 주파수 보정도 하지 않는다”는 단순 모형으로 설명하지 않는다. 실제 정밀도는 시간 소스·망 지연·하드웨어·가상화 환경과 설정에 따라 달라진다.

두 구현의 동기화 품질은 offset·frequency와 실제 상태 출력으로 비교한다. 임의로 만든 시간 오차 예시는 성능 측정값으로 사용하지 않는다.

NTP 클라이언트·서버 통신에는 일반적으로 UDP 123 경로가 필요하다. NTS 같은 별도 인증 기능은 해당 버전의 지원과 설정을 확인한다. Ubuntu 24.04에서 흔히 사용하는 systemd 255의 timesyncd에 “기본 TLS/NTS가 제공된다”는 설명을 적용하지 않는다.

systemd-timesyncd 역할 · Chrony 4.5 설정

2. 현재 실행 중인 서비스부터 확인

bash
systemctl status systemd-timesyncd
systemctl status chrony
timedatectl status

패키지의 기본 선택은 OS 릴리스·이미지에 따라 달라질 수 있다. 이 문서의 timesyncd 상태는 당시 Ubuntu 24.04 노드에서 관찰한 사례이며 모든 Ubuntu 환경의 기본값을 뜻하지 않는다.

당시 timesyncd 서비스 출력
plain text
root@lab-node:~# systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/usr/lib/systemd/system/systemd-timesyncd.service; enabled; preset: enabled)
     Active: active (running) since Thu 2025-08-21 03:15:35 UTC; 6 days ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 628 (systemd-timesyn)
     Status: "Idle."
      Tasks: 2 (limit: 14309)
     Memory: 1.4M (peak: 2.5M)
        CPU: 40.873s
     CGroup: /system.slice/systemd-timesyncd.service
             └─628 /usr/lib/systemd/systemd-timesyncd

Aug 21 03:15:34 lab-master-1 systemd[1]: Starting systemd-timesyncd.service - Network Time Synchronization...
Aug 21 03:15:35 lab-master-1 systemd[1]: Started systemd-timesyncd.service - Network Time Synchronization.
Aug 21 03:15:35 lab-master-1 systemd-timesyncd[628]: Network configuration changed, trying to establish connection.
Aug 21 03:15:37 lab-master-1 systemd-timesyncd[628]: Network configuration changed, trying to establish connection.
Aug 21 03:15:48 lab-master-1 systemd-timesyncd[628]: Network configuration changed, trying to establish connection.

active (running)이나 NTP service: active만으로 NTP 응답·동기화 성공을 확정하지 않는다.

3. systemd-timesyncd 설정

drop-in으로 서버 지정

설정 경로는 /etc/systemd/timesyncd.conf와 drop-in 디렉터리다. 기존 파일을 sed로 반복 치환하기보다 적용된 전체 설정을 먼저 확인한다.

bash
systemd-analyze cat-config systemd/timesyncd.conf
sudo mkdir -p /etc/systemd/timesyncd.conf.d

예를 들어 /etc/systemd/timesyncd.conf.d/60-local-ntp.conf에 다음 형태를 작성할 수 있다. 서버 이름은 실제 허용된 NTP 서버로 바꾼다.

plain text
[Time]
NTP=
NTP=ntp.example.internal
FallbackNTP=

첫 NTP=는 누적된 목록 초기화, 다음 줄은 사용할 서버 지정 예다. FallbackNTP=를 비우는 것은 fallback 목록을 초기화하는 선택이며, 원하는 외부 fallback이 있다면 운영 정책에 맞춰 지정한다.

FallbackNTP는 주 NTP 서버가 응답하지 않을 때 언제나 즉시 쓰는 두 번째 서버 목록으로 단순화하지 않는다. 다른 NTP 서버 정보가 없을 때 사용하는 fallback이며, 링크별 NTP 정보와 NTP= 설정의 우선순위를 확인한다.

NTP=가 주석이라는 이유만으로 서버가 전혀 없다고 결론 내리지 않는다. DHCP·링크 설정·컴파일 기본값 등도 확인한다. 값 뒤에 설명을 붙이는 대신 주석은 별도 줄로 적는다.

설정 파일 우선순위와 NTP·FallbackNTP

적용과 확인

bash
sudo systemctl restart systemd-timesyncd
timedatectl status
timedatectl timesync-status
timedatectl show-timesync --all
journalctl -u systemd-timesyncd --since "-10 min"

show-timesync는 timesyncd 전용 상태 조회다. Chrony의 세부 상태를 같은 명령으로 대신 읽지 않는다.

명령별 조회 범위

당시 실패·성공 출력

다음 출력에서는 서비스 실행 상태와 실제 시계 동기화 상태를 구분해 볼 수 있다.

동기되지 않은 상태

plain text
               Local time: Wed 2025-08-27 04:48:55 UTC
           Universal time: Wed 2025-08-27 04:48:55 UTC
                 RTC time: Wed 2025-08-27 04:48:35
                Time zone: UTC (UTC, +0000)
System clock synchronized: no #  실제 싱크가 되고 있는지
              NTP service: active # active상태인지
          RTC in local TZ: no

동기된 상태

plain text
               Local time: Wed 2025-08-27 04:58:27 UTC
           Universal time: Wed 2025-08-27 04:58:27 UTC
                 RTC time: Wed 2025-08-27 04:58:27
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

System clock synchronized: no는 해당 시점의 동기 상태다. 원인이 서버 미지정인지, DNS·네트워크·시간 소스 상태 문제인지까지 이 한 줄로 확정하지 않는다.

당시 서버 설정·응답 상세 기록
plain text
root@lab-node:~# timedatectl show-timesync --all
LinkNTPServers=
SystemNTPServers=time.kriss.re.kr
RuntimeNTPServers=
FallbackNTPServers=ntp.ubuntu.com
ServerName=time.kriss.re.kr
ServerAddress=27.96.158.252
RootDistanceMaxUSec=5s
PollIntervalMinUSec=32s
PollIntervalMaxUSec=34min 8s
PollIntervalUSec=2min 8s
NTPMessage={ Leap=0, Version=4, Mode=4, Stratum=3, Precision=-26, RootDelay=7.812ms, RootDispersion=5.905ms, Reference=AF90A64, OriginateTimestamp=Wed 2025-08-27 04:59:59 UTC, ReceiveTimestamp=Wed 2025-08-27 04:59:59 UTC, TransmitTimestamp=Wed 2025-08-27 04:59:59 UTC, DestinationTimestamp=Wed 2025-08-27 04:59:59 UTC, Ignored=no, PacketCount=3, Jitter=1.082ms }
Frequency=140197

출력의 time.kriss.re.kr, 27.96.158.252와 NTPMessage는 조회 시점의 DNS 해석·응답 결과다.

4. Chrony 설치와 전환

하나의 시스템 시계를 여러 데몬이 동시에 조절하지 않도록 서비스 선택을 관리한다. Ubuntu의 패키지 충돌·대체 관계는 설치 계획에서 먼저 확인한다.

bash
sudo apt-get -s install chrony

# 시뮬레이션의 설치·제거 목록 확인 후
sudo apt-get install chrony
systemctl status chrony

timesyncd와 Chrony의 전환 범위는 설치된 패키지와 설정 보존 여부에 따라 달라진다. 패키지 관리자의 변경 계획에는 제거·설치 대상이 표시된다.

dpkg --remove는 .deb 파일명이 아닌 설치된 패키지 이름을 대상으로 한다. 의존성도 검사하지만 apt처럼 저장소에서 필요한 패키지를 찾아 해결하는 역할과는 다르다.

dpkg 설치·제거·의존성 동작

오프라인 설치 기록

실습에 준비한 패키지 버전은 다음과 같다.

plain text
chrony_4.5-1ubuntu4.2_amd64.deb
tzdata-legacy_2025b-0ubuntu0.24.04.1_all.deb

apt-get install --download-only chrony는 온라인 준비 시스템의 패키지 상태를 기준으로 받는다. 두 파일만 있으면 모든 Ubuntu 24.04 대상에서 의존성이 충족된다고 보장하지 않는다. 대상 릴리스·아키텍처·설치 상태에 맞는 전체 의존성 집합을 준비해야 한다.

당시 Chrony 서비스 기동 기록
plain text
root@lab-node:/var/cache/apt/archives# systemctl status chrony
● chrony.service - chrony, an NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chrony.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-08-27 03:36:02 UTC; 1h 38min ago
       Docs: man:chronyd(8)
             man:chronyc(1)
             man:chrony.conf(5)
    Process: 13264 ExecStart=/usr/lib/systemd/scripts/chronyd-starter.sh $DAEMON_OPTS (code=exited, status=0/SUCCESS)
   Main PID: 13273 (chronyd)
      Tasks: 2 (limit: 9484)
     Memory: 1.3M (peak: 2.6M)
        CPU: 49ms
     CGroup: /system.slice/chrony.service
             ├─13273 /usr/sbin/chronyd -F 1
             └─13274 /usr/sbin/chronyd -F 1

Aug 27 03:36:02 lab-bastion chronyd[13273]: chronyd version 4.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 -DEBUG)
Aug 27 03:36:02 lab-bastion chronyd[13273]: Loaded 0 symmetric keys
Aug 27 03:36:02 lab-bastion chronyd[13273]: Frequency -3.474 +/- 2.597 ppm read from /var/lib/chrony/chrony.drift
Aug 27 03:36:02 lab-bastion chronyd[13273]: Using right/UTC timezone to obtain leap second data
Aug 27 03:36:02 lab-bastion chronyd[13273]: Loaded seccomp filter (level 1)

5. Chrony 설정과 보정 방식

Ubuntu 실습의 설정 파일은 /etc/chrony/chrony.conf였다. 배포판에 따라 경로가 다를 수 있다.

서버 지정의 핵심 형태는 다음과 같다.

plain text
# 사용할 시간 소스: 실제 NTP 서버로 변경
server ntp.example.internal iburst

서버를 바꾸려면 기존 pool·server뿐 아니라 include된 파일과 DHCP sources도 확인한다. 새 server 한 줄을 추가했다고 다른 소스가 자동 비활성화되지는 않는다.

Chrony 4.5 문서의 주석은 줄 처음의 #, !, ;, % 등으로 시작하는 형식이다. 지시문 뒤에 설명을 섞지 않고 별도 줄로 작성한다.

기존 구성의 주요 값

  • driftfile: 시계 주파수 오차 추정값을 저장한다.
  • rtcsync: 지원 환경에서 RTC를 커널 동기화 방식으로 다루도록 한다.
  • makestep 1 3: 처음 세 번의 시계 업데이트에서 큰 오차에 step 보정을 허용하는 설정이다.
  • leapsectz right/UTC: 윤초 관련 정보를 사용하는 설정으로, 시간 소스의 leap smear 방식과 일관되게 구성한다.

step은 시각을 점프시키는 보정, slew는 속도를 조절해 오차를 줄이는 보정이다. “Chrony는 절대로 점프하지 않는다”거나 “timesyncd는 항상 점프한다”는 구분은 하지 않는다.

당시 chrony.conf 전체 설정
plain text
# Welcome to the chrony configuration file. See chrony.conf(5) for more
# information about usable directives.

# Include configuration files found in /etc/chrony/conf.d.
confdir /etc/chrony/conf.d

# This will use (up to):
# - 4 sources from ntp.ubuntu.com which some are ipv6 enabled
# - 2 sources from 2.ubuntu.pool.ntp.org which is ipv6 enabled as well
# - 1 source from [01].ubuntu.pool.ntp.org each (ipv4 only atm)
# This means by default, up to 6 dual-stack and up to 2 additional IPv4-only
# sources will be used.
# At the same time it retains some protection against one of the entries being
# down (compare to just using one of the lines). See (LP: #1754358) for the
# discussion.
#
# About using servers from the NTP Pool Project in general see (LP: #104525).
# Approved by Ubuntu Technical Board on 2011-02-08.
# See http://www.pool.ntp.org/join.html for more information.
#pool ntp.ubuntu.com        iburst maxsources 4
#pool 0.ubuntu.pool.ntp.org iburst maxsources 1
#pool 1.ubuntu.pool.ntp.org iburst maxsources 1
#pool 2.ubuntu.pool.ntp.org iburst maxsources 2
server time.kriss.re.kr iburst 

# Use time sources from DHCP.
sourcedir /run/chrony-dhcp

# Use NTP sources found in /etc/chrony/sources.d.
sourcedir /etc/chrony/sources.d

# This directive specify the location of the file containing ID/key pairs for
# NTP authentication.
keyfile /etc/chrony/chrony.keys

# This directive specify the file into which chronyd will store the rate
# information.
driftfile /var/lib/chrony/chrony.drift

# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony

# Uncomment the following line to turn logging on.
#log tracking measurements statistics

# Log files location.
logdir /var/log/chrony

# Stop bad estimates upsetting machine clock.
maxupdateskew 100.0

# This directive enables kernel synchronisation (every 11 minutes) of the
# real-time clock. Note that it can't be used along with the 'rtcfile' directive.
rtcsync

# Step the system clock instead of slewing it if the adjustment is larger than
# one second, but only in the first three clock updates.
makestep 1 3

# Get TAI-UTC offset and leap seconds from the system tz database.
# This directive must be commented out when using time sources serving
# leap-smeared time.
leapsectz right/UTC

Chrony 지시문과 보정 설정

6. Chrony 동기 상태 읽기

bash
sudo systemctl restart chrony
chronyc tracking
chronyc sources -v
timedatectl status
journalctl -u chrony --since "-10 min"

상태 확인 명령은 timedatectl이다. 서비스를 재시작한 직후에는 동기화 판단에 필요한 측정이 충분히 쌓였는지도 확인한다.

tracking

plain text
root@lab-node:/var/cache/apt/archives# chronyc tracking
Reference ID    : 1B609E51 (27.96.158.81)
Stratum         : 4
Ref time (UTC)  : Wed Aug 27 05:37:32 2025
System time     : 0.000238193 seconds fast of NTP time
Last offset     : +0.000214971 seconds
RMS offset      : 0.000123589 seconds
Frequency       : 2.468 ppm slow
Residual freq   : +0.011 ppm
Skew            : 0.205 ppm
Root delay      : 0.008738327 seconds
Root dispersion : 0.005810851 seconds
Update interval : 518.9 seconds
Leap status     : Normal

System time, Last offset, RMS offset은 서로 다른 오차 정보를 나타낸다. Frequency는 주파수 오차 추정, Leap status는 동기 관련 상태다. Normal 한 항목만으로 요구 정밀도를 만족했다고 결론 내리지 않는다.

sources

plain text
root@lab-node:/var/cache/apt/archives# chronyc sources
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 27.96.158.81                  3   9   377    47   +276us[ +491us] +/-   11ms

^는 서버 소스, *는 현재 선택된 소스를 나타낸다. Reach는 8진수 도달성 기록으로 377은 최근 여덟 번의 유효 응답이 모두 있었다는 의미다. 단순 성공 횟수나 ms 단위가 아니다.

선택 불가능한 소스 사례

plain text
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^? registry.example.com       0   7     0     -     +0ns[   +0ns] +/-    0ns

^?는 현재 동기 소스로 선택할 수 없는 상태다. 응답 불가 외에도 상대 미동기화·측정 부족 등이 있을 수 있다. 위 기록은 Reach가 0이라 응답 경로를 먼저 점검할 근거가 있지만, 그 이름이 NTP 서버가 아니라는 원인까지 확정하지는 않는다.

chronyc tracking·sources 필드

7. DNS·네트워크·시간 표시를 나누어 점검

  1. 의도한 NTP 서비스 하나가 실행 중인지 확인한다.
  2. 적용된 설정과 DNS가 실제 어느 소스를 가리키는지 확인한다.
  3. UDP 123 요청·응답 경로와 서버 접근 정책을 확인한다. ping 성공은 NTP 성공을 증명하지 않는다.
  4. 선택 상태·마지막 응답·오차가 시간이 지나며 정상화되는지 확인한다.
  5. UTC와 로컬 시간대 표시를 구분한다. 표시 시간대 변경은 NTP 오차 조정과 다른 작업이다.
당시 DNS 조회와 최종 timedatectl 기록
plain text
root@lab-node:/var/cache/apt/archives# nslookup time.kriss.re.kr
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
time.kriss.re.kr        canonical name = ntp.kriss.re.kr.
Name:   ntp.kriss.re.kr
Address: 27.96.158.252
Name:   ntp.kriss.re.kr
Address: 27.96.158.81
plain text
               Local time: Wed 2025-08-27 05:39:04 UTC
           Universal time: Wed 2025-08-27 05:39:04 UTC
                 RTC time: Wed 2025-08-27 05:39:04
                Time zone: UTC (UTC, +0000)
System clock synchronized: yes # 싱크 여부 확인
              NTP service: active
          RTC in local TZ: no

이 기록은 실습에서 선택한 시간 소스와 synchronized 상태를 확인한 결과다. 현재 서버 상태를 점검하거나 장기간 정밀도를 평가하려면 별도로 측정해야 한다.