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:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 0 comments... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum