Monday 21 October 2013

Network Time Protocol

By – Kunal Raykar

NETWORK TIME PROTOCOL Solaris 10

Network Time Protocol (NTP) is a networking protocol for clock synchronization between computer
systems.
On Solaris 10 ntp service is controlled by svcadm.
#svcs -a | grep ntp
online 13:09:43 svc:/network/ntp:defaul
t

The NTP servers advertise every 64 seconds, by means of a multicast address (224.0.1.1), that they are NTP servers. NTP server multicasts when the xntpd process starts. View the line that causes the system to act as an NTP server by typing the following:

myhost# grep broadcast /etc/inet/ntp.server
broadcast 224.0.1.1 ttl 4


Local NTP servers answer the multicast advertisements. The NTP client sends request packets to all the
NTP servers that it knows. Included in the request packet is the client’s local time. The NTP server replies
by inserting UTC time into the packet and then returns the packet to the client. The client compares its
original request time with its own time when it receives the response from the server. This allows the
client to determine how long the packet was in transit on the network.

The client uses the UTC time value from the NTP server after it receives several responses from the NTP
server. It can take up to five minutes for an NTP client to synchronize with an NTP server.
The /etc/inet/ntp.server file is a template for configuring an NTP server. Copy this file to
/etc/inet/ntp.conf, and edit it to meet your network’s requirements. When viewing the ntp.server file
contents, remember that an NTP server is also an NTP client.

Here we have 2 machine 10.0.4.61(server) and 10.0.4.62(client)
SERVER SIDE CONFIGURATION
Using an Undisciplined Local Clock

NTP servers can, but should not, use their own undisciplined local clock as an official, reliable time source.
To use an undisciplined local clock, complete the following steps:
Copy the /etc/inet/ntp.serverfile to the /etc/inet/ntp.conffile.

myhost# cp /etc/inet/ntp.server /etc/inet/ntp.conf

Open the /etc/inet/ntp.conf file for editing, and change the server IP address to 127.127.1.0, where the
number 1 represents the undisciplined local clock. Comment out the fudge keyword because special
configuration is not needed for the local reference clock.

myhost# vi /etc/inet/ntp.conf

Change:
server 127.127.XType.0 prefer
fudge 127.127.XType.0 stratum 0

to:
server 127.127.1.0 prefer
# fudge 127.127.XType.0 stratum 0


Note – Choices for XType are listed in the comments of the /etc/inet/ntp.server file.

3. Create a drift file as specified by the drift file /var/ntp/ntp.drift entry in the /etc/inet/ntp.conf file:

#touch /var/ntp/ntp.drift

NOTE:The units for the drift file are "PPM", or "parts per million". Your clock will drift due to fluctuations in the frequency oscillating the quartz crystal on your motherboard. A fluctuation of just 0.001% means losing or gaining about 1 second per day. NTP has finer grained control than that, so we look at errors of margin using 0.0001%. Thus:

1 PPM = 1 part per million = 1 microsecond per second = 3.6ms per hour = 86.4ms per day.
My drift file shows the value of "2.643" which means my clock is off by 2.643 parts per million, which means it's currently off at 228.3552ms per day.


CLIENT SIDE CONFIGURATION:
On client side copy /etc/inet/ntp.client to /etc/inet/ntp.conf
And modify the ntp.conf with following changes.
Change
multicastclient 224.0.1.1
to
server 10.0.4.61

Restart the service of ntp on both client and server
#svcadm restart ntp
NOTE: Sometime you have to take reboot of machine in order for changes to take effect. In such cases reboot the server first and then client.
This is not the recommended technique, but sometime it is required.


NTPQ Command :
ntpq is used to query ntp servers about status. The most commonly used option to ntpq is -p (“Print a list
of the peers known to the server as well as a summary of their state.”).
Here we have example:

bash-3.00#
bash-3.00# ntpq -p
remote refid st t when poll reach delay offset disp
==============================================================================
*10.0.4.61 LOCAL(0) 4 u 27 64 377 0.56 60.489 2.53
bash-3.00#


where:
remote: The address of the remote peer
refid:The reference ID (0.0.0.0 if the ref ID is unknown)
st: The stratum of the remote peer
t: The type of the peer (local, unicast, multicast or broadcast) when the last packet was received
poll:The polling interval in seconds
reach:The reachability register, in octal delay, offset, disp:The current estimated delay offset and dispersion of the peer, all in milliseconds.

No comments:

Post a Comment

Physical P2V migration in Solaris (Solaris 9 to Solaris 10)

Physical P2V migration in Solaris  P2V migration is the excellent feature of Solaris where you can migrate the physical server...