ntpq -pn 超时,(因为我认为)nptd 没有绑定到::1,为什么?

ntpq -pn 超时,(因为我认为)nptd 没有绑定到::1,为什么?
Linux myhost 4.1.12-103.7.1.el7uek.x86_64 #(host edited)
Red Hat Enterprise Linux Server release 7.4 (Maipo)
ntpd - NTP daemon program - Ver. 4.2.6p5
ntp-4.2.6p5-25.0.1.el7_3.2.x86_64

/etc/ntp.conf:

driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server someserver iburst #edited
server someserver iburst #edited
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

ntp 像这样运行,因此没有弃用的 -I 接口选项..:

ntp      25451  0.0  0.0  25676  4156 ?        Ss   11:27   0:00 /usr/sbin/ntpd -u ntp:ntp -g

启动时显示:

/usr/sbin/ntpd -n -dd
[...]
Listen and drop on 0 v4wildcard 0.0.0.0 UDP 123
Listen and drop on 1 v6wildcard :: UDP 123
Listen normally on 2 lo 127.0.0.1 UDP 123
Listen normally on 6 vethr9d35e1373f fe80::70f4:4aff:fe83:7639 UDP 123    
[...]

并且它还说了这样一行: create_interface(fe80::70f4:4aff:fe83:7639#123)对于每个接口..但不对于::1

/etc/hosts:

::1         localhost localhost.localdomain localhost6   
localhost6.localdomain6
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
172.27.30.10 hostname1 hostname2
172.27.30.10 hostname3 hostname4
172.27.30.10 hostname5 hostname6

现在首先在故障服务器上对 ntpq 调用进行以下 strace 操作,然后再在正常运行的服务器上进行操作:

strace ntpq -np |& grep -i conn
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET6, sin6_port=htons(123), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
connect(3, {sa_family=AF_UNSPEC, sa_data="\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 16) = 0
connect(3, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(123), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0

并且 ntpq -pn 不起作用:

ntpq -pn
::1: timed out, nothing received
***Request timed out

在类似的服务器上,具有相同的 /etc/hosts,相同的 /etc/ntp.conf 和相同的 kernel/os/ntp 版本create_interface(::1#123)- 但不在我的服务器上。任何指针/尝试的东西都非常感谢。

strace ntpq -np |& grep -i conn
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(4, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_LOCAL, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
connect(3, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(123), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
connect(3, {sa_family=AF_INET6, sin6_port=htons(123), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
connect(4, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
connect(4, {sa_family=AF_INET6, sin6_port=htons(123), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0

并且 ntpq -pn 有效

答案1

对于 ntp-4.2.6p5 及更高版本,尝试将restrict 127.0.0.1或更改restrict 127.0.0.1 mask ...restrict localhost

相关内容