kb:time_sync:ntp:configuration:ntp_conf_file

The ntp.conf File

The ntp.conf file is a text file with configuration information for the NTP daemon, ntpd. On Unix-like systems it is commonly located in the /etc/ directory, on Windows system in the directory C:\Program files (x86)\NTP\etc\ or C:\Program files\NTP\etc\.

ntpd's Shared Memory Driver supports up to 4 devices/instances, using index numbers 0 through 3. See


The 'mbgsvcd' daemon shipped with the Linux driver package feeds the time from up to 4 Meinberg PCI or USB devices into the shared memory segment evaluated by ntpd.

If only a single device is to be supported, the lines below for index 0 are sufficient:

server 127.127.28.0 minpoll 4 maxpoll 4 iburst
fudge 127.127.28.0 refid shm0


If all 4 supported devices are to be used the following lines should be added in addition:

server 127.127.28.1 minpoll 4 maxpoll 4 iburst
fudge 127.127.28.1 refid shm1

server 127.127.28.2 minpoll 4 maxpoll 4 iburst
fudge 127.127.28.2 refid shm2

server 127.127.28.3 minpoll 4 maxpoll 4 iburst
fudge 127.127.28.3 refid shm3


When ntpd starts, it generates some startup messages which are always sent to the system logging facility. On most Unix-like systems this is usually a traditional syslog daemon, but under current Linux version this can also be the journaling subsystem provided by systemd. Under Windows these log messages go to the Windows Application Event log which can be checked using the Event Viewer tool included in Windows.

However, in the ntp.conf file an alternate log file can be specified, so that subsequent log messages eventually go to that file, which can make it difficult to relate the messages from the alternate log file to those from the system log. Especially in case of debugging it may be easier to have all log messages available in the same location . Unfortunately at least the ntp.conf file shipped which some Linux distributions specifies an alternate logfile by default, so maybe the associated lines should be commented out or removed:

# next line specifies an alternate log file
# logfile /var/log/ntp    # commented out here, so no effect


Current versions of ntpd generate only a very limited set of log messages by default during operation. At least in case of debugging it should be helpful to receive more detailed information. The line

logconfig =all

enables all log messages. Please note there must be a space after the logconfig keyword, but there must be no space in =all. See

for details.


Even though the ntpq command can be used to check the current state and time synchronization performance of ntpd, it is often very helpful to let ntpd generate some statistics files. For example the loopstats file shows how the estimated system time offset and drift compensation evolve over time. ntpd can automatically create one new file per day, per week, etc. With a weekly file you can easily see how the clock drift varies cyclically over days, which is due to cyclic variations of the ambient temperature, and how these changes affect the time offset.

enable stats
statsdir /ntp-stats/     # must include the trailing '/'
filegen loopstats file loopstats type week enable

Similarly, additional filegen lines can be added for peerstats, clockstats, and rawstats. Please note that older versions of ntpd may not support all of these additional statistics file types. See:


Please note:

  • Some operating systems or distros may come with a preconfigured statsdir entry, but the line may be commented out.
  • The configured statsdir must exist and ntpd must have write permissions for this directory, especially if ntpd runs as a specific user rather than under the system/root account.
  • If ntpd runs in a chroot jail, the specified directory has to be located inside the jail directory.


If ntpd sometimes runs in a chroot jail and sometimes doesn't, e.g. for testing, then a nice workaround is to create the statistics directory inside the jail directory, and then create a symbolic link outside which points to the statistics directory inside the jail. For example, if the jail directory is /var/lib/ntp and the name of the statistics directory is /ntp-stats/, the following commands can be run to create the directory structure:

sudo mkdir /var/lib/ntp/ntp-stats
sudo ln -s /var/lib/ntp/ntp-stats /ntp-stats
sudo chmod 777 /var/lib/ntp/ntp-stats

With this configuration all statistics files are created in the same directory, regardless whether ntpd runs in a chroot jail or not, and regardless whether it runs under a special user account, or as root. The statistics files are always accessible via the /ntp-stats/ path.


Some systems try to do a dynamic configuration of ntpd at run time. This can be done by a DHCP client which queries and receives one or more NTP server addresses from its DHCP server, or by system specific scripts providing their own way to maintain the configuration.

Depending on the implementation, the reconfiguration can be done by rewriting the original ntp.conf file, by starting ntpd with an alternate configuration file, or by changing ntpd's configuration dynamically at run time.


In some SuSE/openSUSE Linux versions you can specify external NTP servers once by running a command rcntp addserver <yourserver>, and servers specified this way are then added automatically to the NTP configuration when ntpd is started via the system init script.


On some Debian versions as well as Linux versions derived from Debian (e.g. Ubuntu), the DHCP client can create a dynamic ntp.conf file, if the DHCP server provides some NTP configuration information. Depending on the Debian/Ubuntu version, the path to the created file can be e.g.

  • /run/ntp.conf.dhcp or
  • /var/lib/ntp/ntp.conf.dhcp

If this file exists, it is preferred over the static file /etc/ntp.conf, so the effective configuration can differ from the expected one.

You can run the command ps ax|grep ntp to see the command line of the running NTP daemon, including the path to a non-standard configuration file

~# ps ax|grep ntp
 889 ?  Ssl 0:00 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /run/ntp.conf.dhcp -u 127:133


To disable the automatic configuration via DHCP on Debian, Ubuntu, etc., you modify the configuration of the DHCP client:

  • Make a backup copy of the file /etc/dhcp/dhclient.conf
  • Open the file /etc/dhcp/dhclient.conf in a text editor
  • Remove the ntp-servers option from the list of options to request from the DHCP server


For example, the original list of options to request may look like:

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes, ntp-servers;


Remove the highlighted text, so the resulting lines look like:

request subnet-mask, broadcast-address, time-offset, routers,
        domain-name, domain-name-servers, domain-search, host-name,
        dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
        netbios-name-servers, netbios-scope, interface-mtu,
        rfc3442-classless-static-routes;

You probably have to at least restart the DHCP client daemon and then restart the NTP daemon, or simply reboot the system to get rid of the automatic NTP configuration.


If an accurate hardware reference clock such as a PCI card is available, additionally configured NTP servers may cause a degradation of the resulting accuracy. So it is very important to check the effective configuration of the running ntpd instance. A simple way to do this is just to run ntpq -p to see if other time sources beside the expected ones are reported in the output, and marked with a + as candidate , or even with a * as preferred peer.


Martin Burnicki martin.burnicki@meinberg.de, last updated 2022-02-11

  • kb/time_sync/ntp/configuration/ntp_conf_file.txt
  • Last modified: 2022-02-11 12:52
  • by 127.0.0.1