Is there is a simple way to check ntp server IP address configured in my Linux system? Like from which server my system getting time setting and sync time? I want to know time server IP address in Linux.
The defaults can be obtained via two methods.
Method 1: Get ntp server IP address using ntp.conf
Use the grep command to find upstream IP address of the ntp server pool that your system use to sync time:
grep "^pool" /etc/ntp.conf
Here is output from my system:
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 pool ntp.ubuntu.com
This works if you are using ntpd service. One can verify that with the following commands:
pgrep ntpd
ss -tulpn | grep ":123"
netstat -tulpn | grep ":123"
Method 2 If you are using systemd-timesyncd
systemd-timesyncd is a daemon that has been added for synchronizing the system clock across the network. It implements an SNTP client. In contrast to NTP implementations such as chrony or the NTP reference server this only implements a client side, and does not bother with the full NTP complexity, focusing only on querying time from one remote server and synchronizing the local clock to it. Verify it if systemd-timesyncd used on your Linux based system:
timedatectl status
For more info see
https://www.cyberciti.biz/faq/linux-unix-bsd-is-ntp-client-working/
When using systemd-timesyncd, you can configure view ntpd server IP address using the following cat command:
cat /etc/systemd/timesyncd.conf
To see exact upstream IP address of ntp server run
systemctl status systemd-timesyncd
See also Ubuntu Server documentation | Ubuntu