NTP Server and client setup

Time is critical when having many server and using different clusters. So i made this guide to save all my notes when working with time.

Setting local time

I make an link to /etc/timezone

ln -sf /usr/share/zoneinfo/Etc/GMT /etc/timezone

To check if i use the correct time zone

date

Install ntpd

 

Ubuntu

apt-get install ntp

Centos

yum install ntp

 

Set up my ntp server for my other server. My ntp server is and ubuntu server

server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
# Use Ubuntu's ntp server as a fallback.
server ntp.ubuntu.com
#Allow ntp servers

restrict 0.ubuntu.pool.ntp.org nomodify notrap noquery
restrict 1.ubuntu.pool.ntp.org nomodify notrap noquery
restrict 2.ubuntu.pool.ntp.org nomodify notrap noquery
restrict 3.ubuntu.pool.ntp.org nomodify notrap noquery
restrict ntp.ubuntu.com nomodify notrap noquery

# Local users may interrogate the ntp server more closely.

restrict 127.0.0.1

restrict ::1

#allow clients

restrict -4 default kod notrap nomodify nopeer noquery

restrict -6 default kod notrap nomodify nopeer noquery

restrict 10.10.0.0 mask 255.255.255.0 notrap nomodify <--- my local network

On my ntp clients i only set server to my ntp server ip

server 10.10.0.1

Restart ntp servers and test it

ntpq -p