User Tools

Site Tools


archive:freebsd_install_ntp

How To Install NTP On FreeBSD

I prefer to install NTP myself instead of having it installed during installation.

Note: You will need perl installed on your system in order for NTP to work.

If you are using bash and have not allready done so please adjust the search path for all user(s) as shown below in order for FreeBSD to use the manual installed NTP version instead of the one shipped with FreeBSD.

Find the following line in either .profile or .bashrc whatever file your user(s) is using.

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:$HOME/bin; export PATH

Change it so it looks like this.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$HOME/bin; export PATH

Next install NTP.

cd /usr/ports/net/ntp && make install clean BATCH=yes

Create the drift file.

touch /var/db/ntpd.drift 

Adjust the servers we want to sync with. edit the /etc/ntp.conf file to look like below.

server 0.pool.ntp.org iburst
server 1.pool.ntp.org iburst
server 2.pool.ntp.org iburst
server 3.pool.ntp.org iburst

driftfile /var/db/ntpd.drift
logfile /var/log/ntp.log 

Launch NTP at startup. Add the following to /etc/rc.conf

ntpd_enable="YES"
ntpd_config="/etc/ntp.conf"

Either reboot or start NTP manual.

/etc/rc.d/ntpd start

Wait for about 5 to 10 mins and check the status of NTP.

ntpq -p localhost

If NTP is working you should get an output very similar to the one below.

remote 	        refid 	        st 	t 	when 	poll    reach 	delay 	offset 	jitter
=====================================================================
+freesbee.wheel 212.243.86.159 	2 	u 	986 	1024 	377 	4.506 	0.708 	0.123
ntp.ngdc.net 	217.198.219.102 2 	u 	995 	1024 	377 	0.993  -1.658 	0.191
*n1.taur.dk 	.GPS.           1 	u 	26 	1024 	377 	5.548 	1.208 	0.114
+zdani.szn.dk 	192.36.133.17 	2 	u 	31 	1024 	377 	5.107 	7.315 	0.549
archive/freebsd_install_ntp.txt · Last modified: 24/11/2023 12:26 by Allan