I have a few servers with public Internet IP addresses like A.B.C.x
. One of my hosts (A.B.C.10
) runs ntpd and I have it syncing it's time from europe.pool.ntp.org.
Now I only want to allow hosts from my subnet (A.B.C.x
) to be able to sync to A.B.C.10
. By default the whole world can sync to my NTP server. How do I accomplish this?
All examples I can find assume that I'm syncing to specific IP addresses but I sync to DNS names and as far as I can tell the IP addresses that the DNS names x
.europe.pool.ntp.org point to are variable. So I can't setup exceptions in my firewall and I can't use the restrict
option in ntp.conf because it too only accepts IP addresses and not DNS names (Oh! and restrict
applies both to clients and to servers as firewall rules do!)
Basic
ntp.conf
for localnet serving look like thatTwo longest lines deny any access to the server by default and then other
restric
directives allow only specific hosts and subnets.You've got several options, and it depends on where firewalls are placed and/or which ones you prefer to work with. Ideally you would have a firewall that you can control on the subnet. Less ideally you'll only be dealing with a host level firewall on the NTP server. Either way the concept is the same.
For a subnet firewall:
A.B.C.10
For a host firewall on the NTP server:
e.g. to allow 10.0.0.0/8:
I didn't find these answers terribly helpful, so here is what worked for me. This is on a machine running NTP 4.2.6p5
I know this is an old thread, but thought it might help someone. In the example, you should replace whitelist.ip.0, whitelist.ip.1, whitelist.ip.2 with your whitelisted hosts. You can obviously also modify the mask argument to allow, e.g., a /24 network