NTP

Revision 11 as of 2015-12-13 04:01:49

Clear message


Per the following paragraph from http://doc.ntp.org/4.2.0/manyopt.html

It is possible and frequently useful to configure a host as both manycast client and manycast server. A number of hosts configured this way and sharing a common group address will automatically organize themselves in an optimum configuration based on stratum and synchronization distance. For example, consider an NTP subnet of two primary servers and a hundred or more dependent clients. With two exceptions, all servers and clients have identical configuration files including both multicastclient and multicastserver commands using, for instance, multicast group address 239.1.1.1. The only exception is that each primary server configuration file must include commands for the primary reference source such as a GPS receiver.


Per the following paragraph from http://doc.ntp.org/4.2.6/manyopt.html

It is possible and frequently useful to configure a host as both broadcast client and broadcast server. A number of hosts configured this way and sharing a common broadcast address will automatically organize themselves in an optimum configuration based on stratum and synchronization distance.


At the bottom of the file copy and paste:
sudo nano /etc/ntp.conf

# As a server
broadcast 224.0.1.1 ttl 255             #Used with multicastclient
broadcast ff05::101 ttl 255             #Used with multicastclient
manycastserver 224.0.1.1 ttl 255        #Used with manycastclient
manycastserver ff05::101 ttl 255        #Used with manycastclient

# As a client
server 2.oceania.pool.ntp.org burst iburst prefer
server 2.au.pool.ntp.org burst iburst prefer
server 2.nz.pool.ntp.org burst iburst prefer
#broadcastclient                        #Optionally receive from legacy devices
manycastclient 224.0.1.1 ttl 255        #Used with manycastserver
manycastclient ff05::101 ttl 255        #Used with manycastserver
multicastclient 224.0.1.1               #Used with broadcast
multicastclient ff05::101               #Used with broadcast

# Restrict except to those which we allow
restrict 224.0.1.1
restrict 255.255.255.255
restrict ff05::101


Alternatively an automated method of appending the mentioned configuration to the file /etc/ntp.conf is:
echo -e "\n# As a server" | sudo tee -a /etc/ntp.conf \
&& echo -e "broadcast 224.0.1.1 ttl 255\t\t#Used with multicastclient" | sudo tee -a /etc/ntp.conf \
&& echo -e "broadcast ff05::101 ttl 255\t\t#Used with multicastclient" | sudo tee -a /etc/ntp.conf \
&& echo -e "manycastserver 224.0.1.1 ttl 255\t#Used with manycastclient" | sudo tee -a /etc/ntp.conf \
&& echo -e "manycastserver ff05::101 ttl 255\t#Used with manycastclient" | sudo tee -a /etc/ntp.conf \
&& echo -e "\n# As a client" | sudo tee -a /etc/ntp.conf \
&& echo -e "server 2.oceania.pool.ntp.org burst iburst prefer" | sudo tee -a /etc/ntp.conf \
&& echo -e "server 2.au.pool.ntp.org burst iburst prefer" | sudo tee -a /etc/ntp.conf \
&& echo -e "server 2.nz.pool.ntp.org burst iburst prefer" | sudo tee -a /etc/ntp.conf \
&& echo -e "#broadcastclient\t\t\t#Optionally receive from legacy devices" | sudo tee -a /etc/ntp.conf \
&& echo -e "manycastclient 224.0.1.1 ttl 255\t#Used with manycastserver" | sudo tee -a /etc/ntp.conf \
&& echo -e "manycastclient ff05::101 ttl 255\t#Used with manycastserver" | sudo tee -a /etc/ntp.conf \
&& echo -e "multicastclient 224.0.1.1\t\t#Used with broadcast" | sudo tee -a /etc/ntp.conf \
&& echo -e "multicastclient ff05::101\t\t#Used with broadcast" | sudo tee -a /etc/ntp.conf \
&& echo -e "\n# Restrict except to those which we allow" | sudo tee -a /etc/ntp.conf \
&& echo -e "restrict 224.0.1.1" | sudo tee -a /etc/ntp.conf \
&& echo -e "restrict 255.255.255.255" | sudo tee -a /etc/ntp.conf \
&& echo -e "restrict ff05::101" | sudo tee -a /etc/ntp.conf

Restart the daemon:
sudo /etc/init.d/ntp try-restart

Prove that the configuration is correct:
ntptrace
ntpsweep --peer --host 127.0.0.1
ntpsweep --peer --host ::1
ntpsweep --host 224.0.1.1
ntpsweep --host ff05::101


Jonathan Ferguson, Network Time Protocol, https://wiki.ubuntu.com/JonathanFerguson/NTP