Time Zone and NTP - mata-elang-stable/MataElang-Platform GitHub Wiki
OPTIONAL: if your network is not connected to the Internet
If your servers can refer to an NTP server on the Internet, only "Setup NTP client" is required on all servers.
If your servers are put on a closed network, where the Internet is not available, you need to "Build a local NTP server" on your network. After that, "Setup NTP client" is required on all servers.
As for the time zone, this document assumes that you use "Asia/Jakarta" time zone. However, if you manage multiple sensors over different time zones, it is better to set the time zone to "UTC".
Item | Internet Available Network | Closed Network |
---|---|---|
Time Zone | Asia/Jakarta | Asia/Jakarta |
Local NTP Server | - | Necessary |
NTP Server | 0.id.pool.ntp.org | 172.16.2.110 |
Network Address | - | 172.16.2.0/24 |
- To see a list of time zones, use
timedatectl list-timezones
command.
sudo timedatectl set-timezone Asia/Jakarta
sudo timedatectl set-local-rtc false
sudo timedatectl set-ntp true
timesyncd.conf
to specify NTP servers you use.
sudo nano /etc/systemd/timesyncd.conf
Configuration
🔑 If the network is closed, specify the local NTP server here.
#NTP=
NTP=0.id.pool.ntp.org
sudo systemctl restart systemd-timesyncd
✅ Confirm the time synchronization service is active.
systemctl status systemd-timesyncd
Click here to see the result.
● systemd-timesyncd.service - Network Time Synchronization
Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-23 20:14:02 WIB; 25min ago
✅ Check time and date settings.
timedatectl
Result
Local time: Mon 2021-08-23 20:14:02 WIB
Universal time: Mon 2021-08-23 13:14:02 UTC
RTC time: Mon 2021-08-23 13:14:02
Time zone: Asia/Jakarta (WIB, +0700)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
❗ This is an optional installation.
If the Internet is not available on your network, it is necessary to build a local NTP server on Defence Center.
In this case, please follow the steps below. If not, skip here and go to the next installation.
- To see a list of time zones, use
timedatectl list-timezones
command.
sudo timedatectl set-timezone Asia/Jakarta
sudo timedatectl set-local-rtc false
✅ Check time and date settings.
timedatectl
Result
Local time: Mon 2021-08-23 20:14:02 WIB
Universal time: Mon 2021-08-23 13:14:02 UTC
RTC time: Mon 2021-08-23 13:14:02
Time zone: Asia/Jakarta (WIB, +0700)
System clock synchronized: yes
NTP service: active
RTC in local TZ: no
sudo apt update && sudo apt -y upgrade
sudo apt -y install ntp
ntp.conf
for a closed network.
sudo nano /etc/ntp.conf
Configuration
🔑 Set the network address for the Defence Center network to YOUR_NETWORK_ADDRESS
and YOUR_NETMASK
.
### Line 21-24: Comment out the default NTP servers.
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst
### Line 27: Comment out Ubuntu's NTP server.
#pool ntp.ubuntu.com
### Line 51: Add a restriction of time synchronization.
restrict <YOUR_NETWORK_ADDRESS (e.g. 172.16.2.0)> mask <YOUR_NETMASK (e.g. 255.255.255.0)> notrap nomodify
### Line 61-62: Add the local clock settings at the end of the file.
server 127.127.1.0 prefer
fudge 127.127.1.0 stratum 10
sudo systemctl restart ntp
✅ Confirm the NTP service is active.
systemctl status ntp
Click here to see the result.
● ntp.service - Network Time Service
Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-08-23 20:14:02 WIB; 25min ago
✅ Confirm the NTP server is working with its own clock.
ntpq -p
Result
remote refid st t when poll reach delay offset jitter
==============================================================================
*LOCAL(0) .LOCL. 10 l 19 64 1 0.000 0.000 0.000