Search This Blog

Tuesday, July 31, 2012

Synchronize time of two or more PCs with NTP

1) At first check whether NTP is installed or not. Install if its not installed.

#apt-get install ntp

2) Start or restart ntp using

#/etc/init.d/ntp restart/start

3) On server machine do following things.
Open /etc/ntp.conf and add following things


server ntp.ubuntu.com iburst
server pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10


restrict 192.168.10.0 mask 255.255.255.0 nomodify notrap

Here first two lines are external ntp servers which will be used to synchronize to time. 3rd and 4th line is used if machine has infrequent internet connection. Last line is used so that any machine from network 192.168.10.0 can use this machine as a server to synchronize time. So result would be that you would see same time on all machines in that network 192.168.10.0 and current machine(server).

Restart ntp using

#/etc/init.d/ntp restart

4) On client machine
Open /etc/ntp.conf and add ip address of the server machine. We assume that ip address of server machine was 192.168.10.12.

so in ntp.conf enter

server 192.168.10.12 iburst

Restart ntp
# /etc/init.d/ntp restart

Check using following command

#ntpq -c lpeer
And you should see ip address or hostname of server machine.

Thats it. Now onwards all the client machines in the network 192.168.10.0 and server machine(192.168.10.12) will always show same time and will remain synchronized.

No comments: