NTP не синхронизируется в Ubuntu 18.04.02 - PullRequest
0 голосов
/ 03 марта 2020

Моя ОС - Ubuntu 18.04.02 - NTP отсутствует, мне пришлось установить его с помощью apt-get. У меня есть приложение, которое я должен использовать NTP для совместимости. Я отключил и удалил timesyncd, чтобы избежать конфликтов.

Я настроил ntp.conf для использования:

0.north-america.pool.ntp.org

1.north- america.pool.ntp.org

2.north-america.pool.ntp.org

Я могу пинговать их без проблем. Соединение inte rnet в порядке. Служба NTP работает, но постоянно находится в состоянии запроса и не синхронизирует время.

Это просто клиентское устройство IoT. Мне просто нужно синхронизировать время для выполнения наших задач в синхронизации c с другими компьютерами в той же сети.

Чего мне не хватает? Нужно ли включать брандмауэр или порты? Я блокирую IPV6, я добавил -4 к NTPD_OPTS.

$ sudo service ntp status
● ntp.service - Network Time Service
   Loaded: loaded (/lib/systemd/system/ntp.service; enabled; vendor preset: enab
   Active: active (running) since Mon 2020-03-02 13:07:14 EST; 17h ago
     Docs: man:ntpd(8)
  Process: 2078 ExecStart=/usr/lib/ntp/ntp-systemd-wrapper (code=exited, status=
 Main PID: 2090 (ntpd)
    Tasks: 2 (limit: 1600)
   CGroup: /system.slice/ntp.service
           └─2090 /usr/sbin/ntpd -p /var/run/ntpd.pid -4 -g -u 106:113

Mar 03 06:36:13 FD50-AE ntpd[2090]: Soliciting pool server 209.115.181.1
Mar 03 06:36:34 FD50-AE ntpd[2090]: Soliciting pool server 45.33.2.219
Mar 03 06:36:38 FD50-AE ntpd[2090]: Soliciting pool server 64.79.100.197
Mar 03 06:36:55 FD50-AE ntpd[2090]: Soliciting pool server 91.189.91.157
Mar 03 06:37:20 FD50-AE ntpd[2090]: Soliciting pool server 149.56.47.60
Mar 03 06:37:20 FD50-AE ntpd[2090]: bind(19) AF_INET 127.0.0.1#123 flags
Mar 03 06:37:20 FD50-AE ntpd[2090]: unable to create socket on lo (212)
Mar 03 06:37:20 FD50-AE ntpd[2090]: failed to init interface for address
Mar 03 06:37:38 FD50-AE ntpd[2090]: Soliciting pool server 45.63.54.13
Mar 03 06:37:43 FD50-AE ntpd[2090]: Soliciting pool server 173.255.140.3

[1]+  Stopped                 sudo service ntp status

$ ntpstat
unsynchronised
   polling server every 8 s

$ timedatectl
                      Local time: Tue 2020-03-03 06:58:34 EST
                  Universal time: Tue 2020-03-03 11:58:34 UTC
                        RTC time: Tue 2020-03-03 11:58:34
                       Time zone: America/New_York (EST, -0500)
       System clock synchronized: no
systemd-timesyncd.service active: no
                 RTC in local TZ: no

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 0.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 1.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 2.north-america .POOL.          16 p    -   64    0    0.000    0.000   0.000
 ntp.ubuntu.com  .POOL.          16 p    -   64    0    0.000    0.000   0.000
$

$ sudo systemctl status systemd-timesyncd.service
● systemd-timesyncd.service - Network Time Synchronization
   Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd-timesyncd.service(8)

мой ntp .conf ниже:

#interface listen IPv4
#interface ignore IPv6
interface ignore wildcard

# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help

driftfile /var/lib/ntp/ntp.drift

# Leap seconds definition provided by tzdata
leapfile /usr/share/zoneinfo/leap-seconds.list

# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/

statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable

# Specify one or more NTP servers.

# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
# more information.
#pool 0.ubuntu.pool.ntp.org iburst
#pool 1.ubuntu.pool.ntp.org iburst
#pool 2.ubuntu.pool.ntp.org iburst
#pool 3.ubuntu.pool.ntp.org iburst

pool 0.north-america.pool.ntp.org iburst
pool 1.north-america.pool.ntp.org iburst
pool 2.north-america.pool.ntp.org iburst

# Use Ubuntu's ntp server as a fallback.
pool ntp.ubuntu.com

# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
# might also be helpful.
#
# Note that "restrict" applies to both servers and clients, so a configuration
# up blocking replies from your own upstream servers.

# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery limited
restrict -6 default kod notrap nomodify nopeer noquery limited

# Local users may interrogate the ntp server more closely.
restrict 127.0.0.1
restrict ::1

# Needed for adding pool entries
restrict source notrap nomodify noquery

# Clients from this (example!) subnet have unlimited access, but only if
# cryptographically authenticated.
#restrict 192.168.123.0 mask 255.255.255.0 notrust


# If you want to provide time to your local subnet, change the next line.
# (Again, the address is an example only.)
#broadcast 192.168.123.255

# If you want to listen to time broadcasts on your local subnet, de-comment the
# next lines.  Please do this only if you trust everybody on the network!
#disable auth
#broadcastclient

#Changes recquired to use pps synchonisation as explained in documentation:
#http://www.ntp.org/ntpfaq/NTP-s-config-adv.htm#AEN3918

#server 127.127.8.1 mode 135 prefer    # Meinberg GPS167 with PPS
#fudge 127.127.8.1 time1 0.0042        # relative to PPS for my hardware

#server 127.127.22.1                   # ATOM(PPS)
#fudge 127.127.22.1 flag3 1            # enable PPS API

1 Ответ

0 голосов
/ 18 марта 2020

У меня были некоторые проблемы с настройкой компьютера с Ubuntu 18.04. Я просто посмотрел на некоторые журналы, и я мог бы помочь.

$ timedatectl 
                  Local time: Wed 2020-03-18 18:01:20 GMT
              Universal time: Wed 2020-03-18 18:01:20 UTC
                    RTC time: Wed 2020-03-18 18:01:20
                   Time zone: Europe/London (GMT, +0000)
   System clock synchronized: yes

Это вывод my timedatectl. Я должен синхронизировать его, добавив его в "/etc/systemd/timesyncd.conf":

[Time] NTP=10.199.999.99 10.999.999.999

Просто введите IP-адреса серверов, с которыми вы пытаетесь синхронизироваться. Перезапустите timedate и службу ntp и systemd timesyn c. (или перезагрузка :)). И ты должен быть в порядке, я не помню, чтобы что-то еще делал. Надеюсь, это поможет.

...