2

My server provider blocked NTP port because they said there was an NTP attack. Now I cannot sync date and time in my ubuntu 18.04 server.

How can I sync time?

This is ntpdate -q 0.pool.ntp.org result:

server 195.50.171.101, stratum 0, offset 0.000000, delay 0.00000
server 176.235.41.255, stratum 0, offset 0.000000, delay 0.00000
server 86.108.190.23, stratum 0, offset 0.000000, delay 0.00000
server 178.79.155.116, stratum 0, offset 0.000000, delay 0.00000
14 Nov 04:51:06 ntpdate[4027]: no server suitable for synchronization found

This is timedatectl result:

                      Local time: Sat 2020-11-14 05:22:44 EST
                  Universal time: Sat 2020-11-14 10:22:44 UTC
                        RTC time: Sat 2020-11-14 09:55:35
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: yes
                 RTC in local TZ: no
uzaysan
  • 123
  • @guiverc I dont know the exact release. I ınstalled it from web console and it says Ubuntu 18.04 – uzaysan Nov 14 '20 at 08:43
  • @guiverc I have edited title and question. But Do you have any answer to my question? – uzaysan Nov 14 '20 at 08:48
  • 1
    You provider may be blocking inbound connections, but outbound connections should be allowed (unless it is a very dumb ISP :)). Please, try the following command and paste the output in your original question: ntpdate -q 0.pool.ntp.org (You don't need to be root to run this command. But you may have to install it using sudo apt install ntpdate.) – FedKad Nov 14 '20 at 10:06
  • @FedonKadifeli I have edited my question. Please take a look – uzaysan Nov 14 '20 at 10:19
  • Yes. It seems that there is no NTP connection. Can you also paste the output of timedatectl command? – FedKad Nov 14 '20 at 10:21
  • @FedonKadifeli I have added output – uzaysan Nov 14 '20 at 10:24
  • 1
    I suggest you contact your server provider (Can you share their name with us?). Time synchronization is a basic service that any serious server provider should provide. They may have an internal NTP server just for this purpose. – FedKad Nov 14 '20 at 10:27
  • @FedonKadifeli Their name is Keyubu. Local provider. I talked with them about this but they said they cannot enable it soon and I should manually set time – uzaysan Nov 14 '20 at 10:32
  • 1
    I think you live in Turkey and the service provider you are using is keyubu.com. I also live in Turkey, but I have never thought of using a VPS from a Turkish provider, because they are expensive, unreliable and due to heavy Internet censorship in Turkey, you cannot rely on a Turkish provider to do real business. For time synchronization you can do something programmatically by running a script periodically and obtaining the time from a Web server. However, this would not be a very reliable approach. Please search linux time sync without ntp access for some hints. – FedKad Nov 14 '20 at 10:41
  • @FedonKadifeli I'm using Hetzner for important data(such as database). But servers in turkey are microservices that doesnt contain anything important. So even i my server is blocked, I can create a new one in a minute. So. And its cheaper than german providers. Also I found and answer. Will share the answer here – uzaysan Nov 14 '20 at 10:45

1 Answers1

3

You can try the htpdate package. It has a service called htpdate.service.

After installing htpdate with the command sudo apt install htpdate you can monitor its status using the following command:

$ systemctl status htpdate.service

Please, note that this service will not be able to synchronize your clock very precisely, however an error of about one second will be acceptable in your case.

FedKad
  • 10,515