Tuesday, 6 June 2017

Set NTP Server and sync other servers

Greetings, 

This configuration should work with almost all flavours however, in my scenario Ubuntu Server was my NTP Server and Redhat and CentOS were the clients.


Working on NTP Server

  • Make sure NTP UDP port 123 is open, from both server firewall and hardware firewall if your server is behind DMZ, in my case it was.
  •  Once the port is open, lets query and see if we get any replies from NTP Pool. it doesn't matter if you NTP service is running or not just yet.
  # ntpdate -dq 0.uk.pool.ntp.org (d ==> debugging mode to see what's going on, q ==> querying without setting the clock and I chose the best suitable pool)

  • Now, the output must be transmit and receive then you're good to go which can be seen below and if your just getting transmit then there must be something wrong and check firewall iptables and your hardware firewall if you have so, in my case juniper firewall.
  • Let's permanetly set it up. We need to configure NTP config file (ntp.conf) and add suitable pool (http://www.pool.ntp.org/en/)
 # vim /etc/ntp.conf and add your suitable pool

  •  start your ntp service and make sure its running
# service ntp start
# netstat -unlp | grep -i ntp (You should get output of ntp service running)
  • Now, let us update our date and time
# ntpdate -v -b -d 0.uk.pool.ntp.org
  • check if it is working using date command and let us sync it with hwclock which will sync with hardware clock.
# hwclock --systohc

Working on NTP Client Server
  •  Once again, we need to remember that port 123 is open.  We will be configuring ntp.conf but instead of "0.uk.pool.ntp.org" we replace it with "NTP Server IP" and start the NTP Server
  • Let's set the time and date
# ntpdate -v -b -d 192.168.9.10 (server IP)
# hwclock --systohc

waaaalaaa it seems to be out NTP Servers up and running and client server synced with NTP server. 

No comments:

Post a Comment