Categories
linux Microsoft

How to setup time synchronization on servers

In Hyper-V virtualization, a guest virtual machine has something called “Integration Services.” By default, all of these services are pretty much enabled, including time synchronization. However, this can cause big issues if you have virtual Domain Controllers, and your physical host servers are not getting their time from a common, reliable source, such as an external NTP server like 0.us.pool.ntp.org1.nl.pool.ntp.org, etc.

In particular, if a virtual host is running a guest Domain Controller (DC), then the DC will be getting its time from the clock of the physical Hyper-V server at start-up.

Keep only one time authority

There should be only one time authority on the network, which in turn should be synchronized with a reliable NTP server. Hencem, we up our virtual Domain Controller (DC01) to sync with an outside NTP server, and then set other DC02 to refer to the primary DC only.

To see what our server (DC01/DC02) is using as it’s time authority use:

C:\>w32tm /query /source

Disable time synchronization for both Domain Controller VM’s

Hyper-V Manager > Virtual Machine > Settings > Integration Services:

Integration Services
Integration Services Time Synchronization

Set time sync for your Domain Controllers

Next, on your DC01, reset the time authority. Microsoft offers a fix that helps you set an external time source such as “0.us.pool.ntp.org” .

C:\>w32tm /config /syncfromflags:manual /manualpeerlist:"0.us.pool.ntp.org 1.nl.pool.ntp.org" /reliable:yes /update

C:\>Net stop w32time

C:\>Net start w32time

C:\>w32tm /resync /force

Set Hyper-V physical servers to sync time to domain controllers (DC01/DC02)

Take Remote desktop connection to Hyper-V serves (HV01/HV02)

C:\>w32tm /config /syncfromflags:manual /manualpeerlist:"DC01.swatantra.info DC02.swatantra.info" /reliable:yes /update
The command completed successfully.  

C:\>Net stop w32time
The Windows Time service is stopping.
The Windows Time service was stopped successfully. 

C:\>Net start w32time
The Windows Time service is starting.The Windows Time service was started successfully. 

C:\>w32tm /resync /force
Sending resync command to local computerThe command completed successfully.
'Coz sharing is caring
Categories
Apache HTTP Concepts Internet linux Microsoft

How to sync server time with Network Time Protocol server

Sync server time on Linux with NTP

What is NTP?

An Internet protocol is used to synchronise clocks of computers, for instance linux server. This protocol is known as NTP (Network Time Protocol).

Following steps shows how to sync time using the terminal. Before we start login to the server via terminal and follow the steps given below.

Step 1: Check whether NTP is installed

Use the ntpstat command to view the status of the NTP service on the instance. It may happen that you get an error message prompting that NTP is not installed. In that case you have to install it on the server.

# sudo ntpstat
-bash: ntpstat: command not found

Step 2: Install NTP

Use the following command to install NTP on server.

# sudo yum install ntp

Step 3: Start NTP

After the installation is complete we need to start NTP by using the following command.

# sudo systemctl start ntpd

Note!

Enable NTP to start at boot:

# sudo systemctl enable ntpd

Stop NTP:

# sudo systemctl stop ntpd

Restart NTP:

# sudo systemctl restart ntpd

Step 4: Sync Time

For this use the following command.

# sudo ntpdate -q 0.rhel.pool.ntp.org

And restart NTP

# sudo systemctl restart ntpd

…and the server time will be synced.

Sync server time on Windows with SNTP

What is SNTP?

Simple Network Time Protocol (SNTP) is a simplified version of Network Time Protocol (NTP).  This is used to synchronize computer clocks on a network. As name defines simplified version of NTP is generally used when full implementation of NTP is not needed.

SNTP is a simplified access strategy for servers and clients using NTP. This simplified protocol is widely used to synchronizes a computer’s system time with a server that has already been synchronized by a source such as a radio, satellite receiver or modem. 

Interestingly, SNTP supports unicast, multicast and anycast operating modes. In unicast mode, the client sends a request to a dedicated server by referencing its unicast address. Once a reply is received from the server, the client determines the time, roundtrip delay and local clock offset in reference to the server. In multicast mode, the server sends an unsolicited message to a dedicated IPv4 or IPv6 local broadcast address. Generally, a multicast client does not send any requests to the service because of the service disruption caused by unknown and untrusted multicast servers. The disruption can be avoided through an access control mechanism that allows a client to select a designated server he or she knows and trusts.

Use below code to sync server time on windows machine

@echo on & @setlocal enableextensions

@echo =========================
@echo Turn off the time service
net stop w32time

@echo =========================
@echo Set the SNTP (Simple Network Time Protocol) source for the time server

w32tm /config /syncfromflags:manual /manualpeerlist:"0.it.pool.ntp.org 1.it.pool.ntp.org 2.it.pool.ntp.org 3.it.pool.ntp.org"

@echo =========================
@echo ... and then turn on the time service back on

net start w32time

@echo =========================
@echo Tell the time sync service to use the changes

w32tm /config /update

@echo =========================
@echo Reset the local computer's time against the time server

w32tm /resync /rediscover

@endlocal & @goto :EOF
'Coz sharing is caring