≡ Menu

FreeBSD Install OpenNTPD NTP Server / Client To Synchronize The Local Clock

How do I install OpenNTPD ( a Unix system daemon implementing the Network Time Protocol) to synchronize the local clock of a FreeBSD computer system with remote NTP servers called ntp.myisp.com?

Accurate time is important for various UNIX applications such as BIND, Crond, Apache and others. OpenNTPD able to act as an NTP server and as an NTP server to NTP-compatible clients. The default ntpd server cannot bind to specific IP address. If you are planning to use FreeBSD jails, you must disable ntpd and use OpenNTPD.

OpenNTPD Installation

Type the following command to update FreeBSD ports tree:
# portsnap fetch update
To install OpenNTPD server, enter:
# cd /usr/ports/net/openntpd
# make install clean

Configuration Files

  1. /usr/local/sbin/ntpd OpenNTPD network server file.
  2. /usr/local/etc/rc.d/openntpd – OpenNTPD startup scripts to start / stop OpenNTPD server.
  3. /usr/local/etc/ntpd.conf – OpenNTPD configuration file.
  4. TCP / UDP port # 123 – OpenNTPD NTP port.

Open /usr/local/etc/ntpd.conf file, enter:
# vi /usr/local/etc/ntpd.conf
Update configuration as follows:

# Do not listen to all IP, just bind
# openntpd to Ipv4,, IPv6 2607:f0d0:3001:0009:0000:0000:0000:0001
# and loopback
listen on
listen on
listen on 2607:f0d0:3001:0009:0000:0000:0000:0001
listen on
# Sync to a single server
server ntp.myisp.com
# Use a random selection of 8 public stratum 2 servers
servers pool.ntp.org

Turn on OpenNTPD service

Enable OpenNTPD service:
# echo 'openntpd_enable="YES"' >> /etc/rc.conf

Task: Start OpenNTPD Service

# /usr/local/etc/rc.d/openntpd start

Task: Stop OpenNTPD Service

# /usr/local/etc/rc.d/openntpd stop

Task: Restart OpenNTPD Service

# /usr/local/etc/rc.d/openntpd restart

Task: Verify OpenNTPD Service

Find out the status:
# /usr/local/etc/rc.d/openntpd status
Sample output:

openntpd is running as pid 68596 68597.

Verify open port:
# sockstat -4 -p 123
# sockstat -46 -p 123
Sample output:

_ntp     ntpd       68597 4  udp4
_ntp     ntpd       68597 6  udp4     *:*
_ntp     ntpd       68597 7  udp4       *:*
_ntp     ntpd       68597 8  udp6   2607:f0d0:3001:9::1:123*:*
_ntp     ntpd       68597 9  udp4         *:*
_ntp     ntpd       68597 10 udp4
_ntp     ntpd       68597 11 udp4
_ntp     ntpd       68597 12 udp4
_ntp     ntpd       68597 13 udp4
_ntp     ntpd       68597 14 udp4

Open Outgoing Port Port # 123 via PF firewall

Update your /etc/pf.conf as follows:

 # Note $ext_if is your interface facing the Internet
# Useful for dedicated FreeBSD server #
# Ipv4 Open outgoing port TCP 123 (NTP)
pass out on $ext_if proto tcp to any port ntp
# Ipv6 Open outgoing port TCP 123 (NTP)
pass out on $ext_if inet6 proto tcp to any port ntp
# Ipv4 Open outgoing port UDP 123 (NTP)
pass out on $ext_if proto udp to any port ntp
# Ipv6 Open outgoing port UDP 123 (NTP)
pass out on $ext_if inet6 proto udp to any port ntp

Reload pf firewall rules:
# /sbin/pfctl -nf /etc/pf.conf && /etc/rc.d/pf reload

Further readings:

Share this tutorial on:
{ 0 comments… add one }
Security: Are you a robot or human?

Leave a Comment

You can use these HTML tags and attributes: <strong> <em> <pre> <code> <a href="" title="">

   Tagged with: , , , , , , , , , , , , , , ,