See all FreeBSD related FAQ
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

Keeping accurate time on your server 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 the 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
# pkg update && pkg upgrade
To install OpenNTPD server, enter:
# cd /usr/ports/net/openntpd
# make install clean

# pkg install openntpd
Sample outputs:

Fig.01: FreeBSD installing OpenNTPD using pkg command

Fig.01: FreeBSD installing OpenNTPD using pkg command

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
# Use a random selection of 8 public stratum 2 servers

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
# service openntpd start

Task: Stop OpenNTPD Service

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

Task: Restart OpenNTPD Service

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

Task: Verify OpenNTPD Service

Find out the status:
# /usr/local/etc/rc.d/openntpd status
# service 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:

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.