I have a raspberry pi I use for an irrigation system. The problem is it doesn't have hardware clock so, every time it reboots, the system time is wrong, and I cannot set it to sync it automatically.
I have discover that when the system time is wrong, dns requests doesn't work, so every time I try to send a request I just get:
[root@alarmpi me]# ntpdate 3.es.pool.ntp.org Error resolving 3.es.pool.ntp.org: Name or service not known (-2) 12 Aug 15:37:15 ntpdate: Can't find host 3.es.pool.ntp.org: Name or service not known (-2) 12 Aug 15:37:15 ntpdate: no servers can be used, exiting
By the way I get the same connection errors if I try to use pacman, wget, python/requests, even ping... So it is a dns thing for sure.
[me@alarmpi ~]$ ping google.com ping: google.com: Name or service not known
If I set the time and date manually, it works again, but I live 300km from where this thing is, and I can't do it manually every day there is a power cut.
[root@alarmpi me]# timedatectl Local time: Mon 2019-08-12 15:47:40 CEST Universal time: Mon 2019-08-12 13:47:40 UTC RTC time: n/a Time zone: Europe/Madrid (CEST, +0200) System clock synchronized: no NTP service: active RTC in local TZ: no [root@alarmpi me]# timedatectl set-ntp false [root@alarmpi me]# timedatectl set-time "2019-08.13 10:45:45 CEST" [root@alarmpi me]# ping google.com PING google.com (22.214.171.124) 56(84) bytes of data. 64 bytes from 126.96.36.199 (188.8.131.52): icmp_seq=1 ttl=54 time=22.7 ms 64 bytes from 184.108.40.206 (220.127.116.11): icmp_seq=2 ttl=54 time=31.6 ms ^C --- google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 292ms rtt min/avg/max/mdev = 22.739/27.161/31.583/4.422 ms [root@alarmpi me]# ntpdate 3.es.pool.ntp.org 13 Aug 10:49:54 ntpdate: adjust time server 18.104.22.168 offset 0.004894 sec
So I'm a little lost here. How can I sync the clock automatically if it doesn't let me connect to the service because I'm out of sync?