Skip to main content

Set date/time on Virtual Appliances

Description

Virtual Appliances are shipped with a default time zone.  This guide will explain how to change the current time zone and set a NTP server for syncing. This is highly recommended on the Server, Booster, and IVS appliances. Really every server and client you manage should use an NTP solution to keep the time in sync because synchronized time generally is needed for encrypted communications to not have errors.

Ingredients

  • One of the virtual appliances, Server, IVS or Booster
  • UDP port 123 open between Server and Remote Time Server

Directions

NTP needs to be installed.  This can be checked by doing:

$ yum list installed | grep ^ntp
ntp.x86_64                            4.2.6p5-28.el7.centos            @base    
ntpdate.x86_64                        4.2.6p5-28.el7.centos            @base 

If it is not there, you can install with:

yum -y install ntp

Setting a Time Server

The time may be synced with an NTP server by doing:

ntpdate pool.ntp.org

pool.ntp.org should resolve to the closest server available.  You may be specific though, e.g. for Singapore:

ntpdate sg.pool.ntp.org

For a full list of servers by their country code see: http://support.ntp.org/bin/view/Servers/StratumOneTimeServers

Or if you have your own internal time server, this could be used.

To permanently set a specific time server, edit the ntp.conf file: 

sudo vi /etc/ntp.conf

Either place a # before the current ntp servers set in the file and add the chosen ntp server instead or specify an additional server as a preference.  From the example above:

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
server sg.pool.ntp.org prefer

Start as Service

To start the service and ensure it is on after rebooting:

CentOS 7
systemctl start ntpd
systemctl enable ntpd

Setting the Time Zone

CentOS 7

Current status may be viewed with the following command, which will show amongst other things:

$ timedatectl status
    Time zone: Europe/Zurich (CEST, +0200)
    NTP enabled: yes
    NTP synchronized: yes

In this example, location is set to Zurich.  

All locations can be found with:

timedatectl list-timezones

To change the location involves running the following command with the chosen zone, taking the example of Singapore:

timedatectl set-timezone Asia/Singapore

Confirmation

Once completed, confirm the time and date:

$ date
Wed  5 Sep 17:30:01 +08 2018

Note +08, time difference for, in this case, Singapore