Close Menu
DPC Virtual Tips
    Read More

    Docker Containers Not Starting on Boot? Fix Restart Policies

    August 30, 2026

    How to Troubleshoot Packet Drops on an ESXi Host

    August 16, 2026

    SlurmDBD Is Down: What Continues Working and What Does Not

    August 15, 2026
    • Home
    • About Us
    • Contact
    • Cookie Policy
    • Comment Policy
    • Privacy Policy
    • Terms of Use
    • Disclaimer
    Monday, August 31
    DPC Virtual Tips
    • Home
    • Operating Systems
    • HPC
    • Virtualization
    • About the Author
    • About Us
    • Contact
    DPC Virtual Tips
    Home » Changing NTP Settings on ESXi Hosts
    Virtualization

    Changing NTP Settings on ESXi Hosts

    DaniloBy DaniloMay 19, 2025Updated:August 29, 2026No Comments4 Mins Read
    Facebook Twitter Pinterest LinkedIn Tumblr Email
    vCenter NTP configuration
    Share
    Facebook Twitter LinkedIn Pinterest Email

    Changing NTP Settings on ESXi Hosts is an article that shows an automated approach to changing the NTP client configurations on all connected ESXi hosts under the same vCenter Server, using a Python script, similar to what we did for changing DNS settings on ESXi hosts.

    Correct time synchronization is critical according to VMware’s documentation in a virtualized environment: ESXi hosts rely on accurate clocks for logs, certificates, and features such as vSphere HA. When several hosts need their NTP configuration updated, doing it manually through the vSphere Client is repetitive and error-prone. This script applies the change from a single Linux server, consistently and repeatably.

    The approach

    The idea is to use a Linux server (CentOS 9) as a “script server”. From this server, a Python script connects to vCenter and to each ESXi host to update the NTP client configuration.

    The script uses two Python libraries:

    • pyvmomi — the official VMware vSphere Python SDK, used to talk to the vCenter API.
    • paramiko — a Python SSH library, used to connect directly to the ESXi hosts.

    Step 1 — Install the Linux server

    Install CentOS 9 without a GUI. We tested the procedure with CentOS 9, but feel free to use a different Linux distribution and adjust the script to run on it.

    Step 2 — Install Python on the server

    Access the server by SSH with root rights and install Python automatically:

    curl -O https://raw.githubusercontent.com/danchiacchio/scripts/refs/heads/main/sh_PythonInstall/install-python.sh

    chmod +x install-python.sh

    ./install-python.sh

    Grab a coffee and wait for a while. The automated Python install takes a while to complete! ☕

    Step 3 — Create a working directory

    Create a directory for the script (you can choose any name):

    mkdir -p /root/scripts/py_vESXiNTPd

    Step 4 — Download the script and its dependencies

    Go to the directory, download the script, and install the libraries:

    cd /root/scripts/py_vESXiNTPd
    
    curl -O https://raw.githubusercontent.com/danchiacchio/scripts/refs/heads/main/py_vESXiNTPd/py_ESXiNTPd.py
    
    pip install pyvmomi paramiko

    Step 5 — Create the NTP client configuration file

    Create the file that the script will apply to each host:

    touch ntp_config.txt

    Add the NTP configuration to it. This is an example for an ESXi host — adjust it to your environment:

    restrict default nomodify notrap nopeer noquery
    restrict 127.0.0.1
    restrict -6 ::1
    driftfile /etc/ntp.drift
    logconfig +clockstatus +peerstatus +sysstatus +syncstatus
    server 192.168.255.3
    tos maxdist 30

    A quick explanation of the lines:

    • restrict — access control for NTP: nomodify notrap nopeer noquery limits what remote hosts can do.
    • restrict 127.0.0.1 and restrict -6 ::1 — allow the local host (IPv4 and IPv6) full access.
    • driftfile — where ntpd stores the measured clock drift between restarts.
    • logconfig — enables logging of clock, peer, system, and sync status changes.
    • server 192.168.255.3 — the NTP server the host will synchronize with.
    • tos maxdist 30 — sets a quality threshold (maximum distance) for time sources.

    Step 6 — Run the script

    Make it executable and run it:

    chmod 700 py_ESXiNTPd.py
    
    python3 py_ESXiNTPd.py

    The script is a menu-based tool. After it runs, you can, for example, get the ntpd status for hosts in a specific cluster, or view the NTP configuration of a particular host. To update or change the NTP configuration, select option five and point it to the ntp_config.txt file you created earlier.

    This is a base-menu script and is very user-friendly — explore the options to get familiar with them:

    Check status of the NTP daemon

    After running the script, for instance, we can get the ntpd status for hosts in a specific cluster:

    Get NTP configuration

    To get the NTP configuration for a particular ESXi host:

    A note on production use

    I tested this script several times in a lab environment and it worked as expected. However, be careful when running it in production — applying the wrong NTP server across multiple hosts can cause time drift and related issues. Test in a lab first and verify the result after.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleUpgrading VMware Tools on ESXi Hosts
    Next Article Changing DNS Settings on ESXi Hosts
    Danilo

    Infrastructure Engineer with experience in Virtualization, Linux, Windows Server and learning automation using Python. DPC Virtual Tips was created to share practical tutorials, lab experiences and troubleshooting guides focused on enterprise infrastructure technologies.

    Related Posts

    How to Troubleshoot Packet Drops on an ESXi Host

    August 16, 2026

    VM Replication with vSphere Replication and Site Recovery Manager

    June 16, 2025

    Changing DNS Settings on ESXi Hosts

    May 20, 2025

    Comments are closed.

    Search
    Categories
    • HPC (12)
    • Operating Systems (86)
    • Virtualization (152)
    Read More
    Operating Systems

    Docker Containers Not Starting on Boot? Fix Restart Policies

    By DaniloAugust 30, 20260
    Virtualization

    How to Troubleshoot Packet Drops on an ESXi Host

    By DaniloAugust 16, 20260
    HPC

    SlurmDBD Is Down: What Continues Working and What Does Not

    By DaniloAugust 15, 20260
    HPC

    How to Investigate Jobs Stuck in COMPLETING State on Slurm

    By DaniloAugust 14, 20260
    Operating Systems

    Linux Server Has Free Memory but Is Swapping: Why?

    By DaniloAugust 13, 20260
    Latest Posts

    Docker Containers Not Starting on Boot? Fix Restart Policies

    August 30, 2026

    How to Troubleshoot Packet Drops on an ESXi Host

    August 16, 2026

    SlurmDBD Is Down: What Continues Working and What Does Not

    August 15, 2026
    Images from Gallery
    hpc main commands
    linux commands
    install rock linux
    lustre fs
    shell scripting
    vSAN Trace Files
    Categories
    • HPC
    • Operating Systems
    • Virtualization
    • Home
    • About Us
    • Contact
    • Cookie Policy
    • Comment Policy
    • Privacy Policy
    • Terms of Use
    • Disclaimer
    Copyright © 2026, DPC Virtual Tips. All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.

    We use cookies to ensure your best experience on our website. If you continue using our website, we'll assume you agree to our cookie policy