Following up on a post yesterday, I think I have my PC-BSD machine set up for NTP. I followed some advice from the Handbook (of course), as well as some from a thread on the FreeBSD Questions mailing list. I wanted it to be an NTP server for my internal network, and to sync the date periodically from the 'net. It runs 24/7, so I can't depend on a reboot to set the time. So here's what I did.
First I added the following to my /etc/rc.conf:
ntpd_enable="YES"
This sets it up so that the script at /etc/rc.d/ntpd gets run at boot up, and the ntpd daemon is allowed to run. But now we have to create a config file for it, at a bare minimum. My /etc/ntp.conf file looks like:
server 0.north-america.pool.ntp.org
server 1.north-america.pool.ntp.org
server 2.north-america.pool.ntp.org
server pool.ntp.org
driftfile /var/db/ntp.drift
restrict 192.168.204.100 mask 255.255.255.0 nomodify notrap
restrict localhost
As I'm located in North America, I'm using the pool servers from there, as mentioned here. I don't think I need to specify the driftfile, as it is the same as the default. And combining Matthew Seaman's post with the handbook page, I came up with the restrict lines to allow my internal network to up date from my server. The 'restrict localhost' line actually allows all access to the localhost. Makes sense, eh? Be sure to not make the same mistake the poster in the mailing list made, and just add a 'restrict default ignore' line to the rc.conf file, like the handbook suggests. This means that the NTP daemon can't do anything, even on the local host, which isn't all that useful now is it?
Now I can run the command with the -q flag (which mimics what the older 'ntpdate' command used to do). This just runs the ntpd daemon, does its thing, and exits. This is what it looks like:
$ ntpd -q
[... long pause while it does its dance ...]
ntpd: time set +39.114227s
And now my time is spot on, at least according to Time & Date.com. So now I fire up the daemon and we should be all set:
$ /etc/rc.d/ntpd start
Starting ntpd.
You can use the ntpq command to ask about it. Here we'll ask about the list of peers it is using:
$ ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
static-141-156- .GPS. 1 u 1 64 1 49.416 -0.157 0.001
tire.patch.com 63.192.96.3 3 u - 64 1 118.075 -3.792 0.001
gandalf.llorien .INIT. 16 u - 64 0 0.000 0.000 4000.00
elrond.llorien. .INIT. 16 u - 64 0 0.000 0.000 4000.00
There are a bazillion commands for ntpq, which I'm sure at least one person out there cares about, but for us mere mortals, we've pretty much exhausted the subject!
No comments:
Post a Comment