Страница 1 из 1

Не запускается ntpd

Добавлено: 2015-07-17 14:16:01
Vlad5503
Исправлял конфиг ntp.
А теперь он не хочет запускаться, выдает следующее:

Код: Выделить всё

# /etc/rc.d/ntpd start
Starting ntpd.
ERROR:  only one configfile option allowed
ntpd - NTP daemon program - Ver. 4.2.4p8
USAGE:  ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]...
/etc/rc.d/ntpd: WARNING: failed to start ntpd
Конфиг файл такой:

Код: Выделить всё

# cat /etc/ntp.conf
#
# $FreeBSD: release-9.3
#
disable monitor
restrict default ignore
server 65.55.56.206 iburst burst
server 194.149.67.129 iburst burst
server 93.185.187.110 iburst burst
server 89.221.207.113 iburst burst
server 95.140.94.2 iburst burst
server 212.233.218.5 iburst burst
server 77.73.136.46 iburst burst
server 109.195.19.73 iburst burst

driftfile /var/log/drift

logfile /var/log/ntp.log

restrict 10.11.11.0 mask 255.255.255.0 nomodify notrap
restrict 172.16.0.0 mask 255.255.0.0 nomodify notrap
restrict 10.50.50.0 mask 255.255.255.0 nomodify notrap
restrict 127.0.0.1

restrict 65.55.56.206
restrict 194.149.67.129
restrict 93.185.187.110
restrict 89.221.207.113
restrict 95.140.94.2
restrict 212.233.218.5
restrict 77.73.136.46
restrict 109.195.19.73
Подскажите где и что не так написал...

устранение уязвимости ntpd

Добавлено: 2015-07-17 15:01:54
Alex Keda
Параметры запуска смотрите

устранение уязвимости ntpd

Добавлено: 2015-07-18 9:26:39
Vlad5503
Alex Keda писал(а):Параметры запуска смотрите
Вы имеете ввиду /etc/rc.d/ntpd ?
Вот его содержимое:

Код: Выделить всё

# cat /etc/rc.d/ntpd
#!/bin/sh
#
# $FreeBSD: releng/9.3/etc/rc.d/ntpd 242153 2012-10-26 18:06:49Z obrien $
#

# PROVIDE: ntpd
# REQUIRE: DAEMON ntpdate FILESYSTEMS devfs
# BEFORE:  LOGIN
# KEYWORD: nojail shutdown

. /etc/rc.subr

name="ntpd"
rcvar="ntpd_enable"
command="/usr/sbin/${name}"
pidfile="/var/run/${name}.pid"
start_precmd="ntpd_precmd"

load_rc_config $name

ntpd_precmd()
{
        rc_flags="-c ${ntpd_config} ${ntpd_flags}"

        if checkyesno ntpd_sync_on_start; then
                rc_flags="-g $rc_flags"
        fi

        if [ -z "$ntpd_chrootdir" ]; then
                return 0;
        fi

        # If running in a chroot cage, ensure that the appropriate files
        # exist inside the cage, as well as helper symlinks into the cage
        # from outside.
        #
        # As this is called after the is_running and required_dir checks
        # are made in run_rc_command(), we can safely assume ${ntpd_chrootdir}
        # exists and ntpd isn't running at this point (unless forcestart
        # is used).
        #
        if [ ! -c "${ntpd_chrootdir}/dev/clockctl" ]; then
                rm -f "${ntpd_chrootdir}/dev/clockctl"
                ( cd /dev ; /bin/pax -rw -pe clockctl "${ntpd_chrootdir}/dev" )
        fi
        ln -fs "${ntpd_chrootdir}/var/db/ntp.drift" /var/db/ntp.drift

        #       Change run_rc_commands()'s internal copy of $ntpd_flags
        #
        rc_flags="-u ntpd:ntpd -i ${ntpd_chrootdir} $rc_flags"
}

run_rc_command "$1"
Файл конфигурации у меня один - /etc/ntp.conf
В скрипте rc.conf указано:

Код: Выделить всё

ntpd_program="/usr/sbin/ntpd"
ntpd_config="/etc/ntp.conf"
ntpd_flags="-c /etc/ntp.conf -l /var/log/ntp.log -p /var/run/ntpd.pid"
ntpd_enable="YES"
Версии ОС и ПО:

Код: Выделить всё

# uname -v
FreeBSD 9.3-RELEASE #2: Wed Dec 17 16:24:13 UTC 2014
и самого NTP

Код: Выделить всё

# /usr/sbin/ntpd -v
/usr/sbin/ntpd: option `var' requires an argument
ntpd - NTP daemon program - Ver. 4.2.4p8

устранение уязвимости ntpd

Добавлено: 2015-07-18 11:15:18
guest
# grep "ntpd_" /etc/defaults/rc.conf
ntpd_enable="NO" # Run ntpd Network Time Protocol (or NO).
ntpd_program="/usr/sbin/ntpd" # path to ntpd, if you want a different one.
ntpd_config="/etc/ntp.conf" # ntpd(8) configuration file
ntpd_sync_on_start="NO" # Sync time on ntpd startup, even if offset is high
ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntpd.drift"
#

вставляем в свой /etc/rc.conf:

ntpd_enable="YES"
ntpd_sync_on_start="YES"

потому как ntpd_program,ntpd_config,ntpd_flags задано в /etc/defaults/rc.conf
и соответствует тому что нужно:

# ps axuww | grep ntpd
root 895 0,0 0,0 22264 2776 ?? Ss 16июн15 0:53,42 /usr/sbin/ntpd -g -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
root 10787 0,0 0,0 12060 1624 ?? Is 11:08 0:00,00 ntpd: [priv] (ntpd)
_ntp 10788 0,0 0,0 12060 1704 ?? S 11:08 0:00,01 ntpd: ntp engine (ntpd)
_ntp 10789 0,0 0,0 12060 1644 ?? I 11:08 0:00,00 ntpd: dns engine (ntpd)
#

устранение уязвимости ntpd

Добавлено: 2015-07-19 10:03:08
mr.fr
Если не уверены, можете еще конфиге ntpd выключить monlist:

Код: Выделить всё

disable monitor

устранение уязвимости ntpd

Добавлено: 2015-07-19 10:32:44
Vlad5503
mr.fr писал(а):Если не уверены, можете еще конфиге ntpd выключить monlist:

Код: Выделить всё

disable monitor
Спасибо, но этот параметр у меня в конфиге включен(первой строкой).

Отправлено спустя 4 минуты 2 секунды:
guest писал(а):# grep "ntpd_" /etc/defaults/rc.conf
ntpd_enable="NO" # Run ntpd Network Time Protocol (or NO).
ntpd_program="/usr/sbin/ntpd" # path to ntpd, if you want a different one.
ntpd_config="/etc/ntp.conf" # ntpd(8) configuration file
ntpd_sync_on_start="NO" # Sync time on ntpd startup, even if offset is high
ntpd_flags="-p /var/run/ntpd.pid -f /var/db/ntpd.drift"
#

вставляем в свой /etc/rc.conf:

ntpd_enable="YES"
ntpd_sync_on_start="YES"

потому как ntpd_program,ntpd_config,ntpd_flags задано в /etc/defaults/rc.conf
и соответствует тому что нужно:

# ps axuww | grep ntpd
root 895 0,0 0,0 22264 2776 ?? Ss 16июн15 0:53,42 /usr/sbin/ntpd -g -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
root 10787 0,0 0,0 12060 1624 ?? Is 11:08 0:00,00 ntpd: [priv] (ntpd)
_ntp 10788 0,0 0,0 12060 1704 ?? S 11:08 0:00,01 ntpd: ntp engine (ntpd)
_ntp 10789 0,0 0,0 12060 1644 ?? I 11:08 0:00,00 ntpd: dns engine (ntpd)
#
Указанные Вами параметры имеют место быть в моих конфигах.
Но сервис ntpd так и не запускается...

Не запускается ntpd

Добавлено: 2015-07-19 23:57:54
Electronik

Не запускается ntpd

Добавлено: 2015-07-20 9:19:41
Vlad5503
Спасибо. :good:
в итоге пришлось убрать две строки из rc.conf:

Код: Выделить всё

#ntpd_config="/etc/ntp.conf"
#ntpd_flags="-c /etc/ntp.conf -l /var/log/ntp.log -p /var/run/ntpd.pid"
Ещё раз спасибо всем.
Теперь буду его проверять в работе.

Не запускается ntpd

Добавлено: 2016-06-14 7:20:23
Vlad5503
Прошло время... Тут обратил внимание что нет синхронизации компов с сервером. Глянул я процессы, а процесса ntpd нет.
Делаю старт:

Код: Выделить всё

/etc/rc.d/ntpd start
Starting ntpd.
И делаю проверку каждые полсекунды...

Код: Выделить всё

# ps -ax | grep ntp
 4294 ??  Ss        0:00.01 /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
 4296  0  S+        0:00.00 grep ntp
 # ps -ax | grep ntp
 4294 ??  Ss        0:00.01 /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
 4298  0  S+        0:00.00 grep ntp
 # ps -ax | grep ntp
 4294 ??  Ss        0:00.01 /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
 4300  0  S+        0:00.00 grep ntp
# ps -ax | grep ntp
 4294 ??  Ss        0:00.01 /usr/sbin/ntpd -c /etc/ntp.conf -p /var/run/ntpd.pid -f /var/db/ntpd.drift
 4302  0  S+        0:00.00 grep ntp
# ps -ax | grep ntp
 4304  0  S+        0:00.00 grep ntp
И через две секунды процесс "упал". Идем в лог ntpd.
Вот что там:

Код: Выделить всё

14 Jun 09:56:18 ntpd[4294]: synchronized to 194.149.67.129, stratum 2
14 Jun 09:56:18 ntpd[4294]: time correction of -3562 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
Лог сообщает, что локальное время отличается от запрашиваемого сервера на 1 час.
Zdump выдает:

Код: Выделить всё

# zdump -v Asia/Barnaul
Asia/Barnaul  Fri Dec 13 20:45:52 1901 UTC = Fri Dec 13 20:45:52 1901 UTC isdst=0 gmtoff=0
Asia/Barnaul  Sat Dec 14 20:45:52 1901 UTC = Sat Dec 14 20:45:52 1901 UTC isdst=0 gmtoff=0
Asia/Barnaul  Mon Jan 18 03:14:07 2038 UTC = Mon Jan 18 03:14:07 2038 UTC isdst=0 gmtoff=0
Asia/Barnaul  Tue Jan 19 03:14:07 2038 UTC = Tue Jan 19 03:14:07 2038 UTC isdst=0 gmtoff=0
Ещё:

Код: Выделить всё

# zdump -v /etc/localtime | grep 2016
 #
Здесь пустой вывод...
Подскажите направление поиска где чего проверить и исправить...

Отправлено спустя 54 минуты 19 секунд:
Обновил таймзону^

Код: Выделить всё

portsnap fetch && portsnap update

Код: Выделить всё

pkg install zoneinfo

Код: Выделить всё

cd /usr/ports/misc/zoneinfo/ && make install clean
/usr/ports/misc/zoneinfo # make reinstall clean
===>  Installing for zoneinfo-2016.d
===>   Registering installation for zoneinfo-2016.d
Installing zoneinfo-2016.d...
Now run tzsetup(8) again to install the right file to /etc/localtime.

===>  Cleaning for zoneinfo-2016.d
/usr/ports/misc/zoneinfo # mc
Теперь zdump выдает:

Код: Выделить всё

zdump -v Asia/Barnaul
.....
Asia/Barnaul  Sat Mar 26 19:59:59 2016 UTC = Sun Mar 27 01:59:59 2016 +06 isdst=0 gmtoff=21600
Asia/Barnaul  Sat Mar 26 20:00:00 2016 UTC = Sun Mar 27 03:00:00 2016 +07 isdst=0 gmtoff=25200
.....
Ещё в локалтайме:

Код: Выделить всё

zdump -v /etc/localtime | grep 2016
(null): warning: zone "/etc/localtime" abbreviation "+06" lacks alphabetic at start
/etc/localtime  Sat Mar 26 19:59:59 2016 UTC = Sun Mar 27 01:59:59 2016 +06 isdst=0 gmtoff=21600
/etc/localtime  Sat Mar 26 20:00:00 2016 UTC = Sun Mar 27 03:00:00 2016 +07 isdst=0 gmtoff=25200
Проверяю время локальное:

Код: Выделить всё

 # date
Tue Jun 14 12:00:56 +07 2016
Во как, время сдвинулось...
Правим для своего времени:

Код: Выделить всё

# date 1100
Tue Jun 14 11:00:00 +07 2016

Далее в логе видим:

Код: Выделить всё

14 Jun 11:01:32 ntpd[65401]: synchronized to 194.149.67.129, stratum 2
14 Jun 11:04:01 ntpd[65401]: time reset +149.426708 s
Если процесс не упадет будем считать вопрос решен.
Чуть позже отпишусь о результате.

Отправлено спустя 15 минут 17 секунд:
спустя чуть более 10-и минут

Код: Выделить всё

# ntpdate -q localhost
server 127.0.0.1, stratum 2, offset -0.000003, delay 0.02565
server 127.0.0.1, stratum 0, offset 0.000000, delay 0.00000
server 127.0.0.1, stratum 0, offset 0.000000, delay 0.00000
server ::1, stratum 2, offset -0.000001, delay 0.02565
14 Jun 11:19:02 ntpdate[66972]: adjust time server ::1 offset -0.000001 sec
Вроде работает....

Не запускается ntpd

Добавлено: 2016-06-14 10:36:27
snorlov
Можно на старте запускать ntpdate, он, в отличии от ntpd, может синхронизировать большие расхождения, с меньшей точностью правда, но и добавить ntpd_sync_on_start="YES" в rc.conf...

Не запускается ntpd

Добавлено: 2016-06-14 22:05:35
Neus
Направление? Мануал читать (man rc.conf):
ntpd_sync_on_start
(bool) If set to ``YES'', ntpd(8) is run with the -g flag,
which syncs the system's clock on startup. See ntpd(8) for
more information regarding the -g option. This is a pre-
ferred alternative to using ntpdate(8) or specifying the
ntpdate_enable variable.