我有一个干净的Debian 7安装,我手动input/etc/ntp.conf中的以下行:
interface ignore wildcard interface listen <local_nic_ip>
希望NTP将不再监听UDP6,但重启之后仍然会:
5:udp 0 0 <local_nic_ip>:123 0.0.0.0:* 9172/ntpd 6:udp 0 0 127.0.0.1:123 0.0.0.0:* 9172/ntpd 8:udp6 0 0 ::1:123 :::* 9172/ntpd
NTP的命令行没有任何exception:
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 121:130
如何阻止NTP监听UDP6端口?
我已经能够在Debian 5/6/7和Ubuntu 12.04上以这种方式禁用IPv6的NTP:
编辑文件/etc/default/ntp并replace
NTPD_OPTS='-g'
通过
NTPD_OPTS='-4 -g'
然后,你可以保留你的指令在ntp.conf ,他们不会被忽略:
interface ignore wildcard interface listen <local_nic_ip>
interface ignore wildcard NTP也将在0.0.0.0监听 interface listen <local_nic_ip> NTP只会监听127.0.0.1 (当然) 这将导致:
# netstat -anp | grep :123 udp 0 0 192.168.0.38:123 0.0.0.0:* 2901/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 2901/ntpd
另外,我确认OpenNTPD听你要求他听更友好的地方(不需要编辑多个configuration文件)。 默认情况下,它会监听无处不在,直到你configuration它(非常安全);)
在configuration文件中,只需取消注释行
listen on 127.0.0.1
并添加行
listen on <local_nic_ip>
结果是 :
# netstat -anp | grep :123 udp 0 0 192.168.0.38:123 0.0.0.0:* 8581/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 8581/ntpd
如果你认为这是一个错误(我当然这样做: ntpd忽略了一个configuration指令),你将不得不把它与包维护者或上游作者。 我不相信他们中的任何一个在这里挂出 – 请参阅包装信息的联系方式。
另外,你也可以尝试其他的NTP实现(比如OpenNTPD–我没有亲自使用它,但是OpenBSD的人对安全性往往是绝对偏执的,所以我想它只能听到它被告知的地方)。
正如Sander指出的那样,你的NTP守护进程正在监听本地主机( 127.0.0.1 & ::1 ) – 如果你担心被本地主机攻击,你可能会遇到比NTP守护进程更大的问题。
守护进程忽略了一个configuration指令,但我不认为这是一个严重的安全问题。
ntpd没有这样做; ntpdate是。 请参阅下面的解释。 我没有这两个在我的conf文件中:
interface ignore wildcard interface listen <local_nic_ip>
我启动和sudo netstat -tunlp给了我这个:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name udp 0 0 127.0.0.1:123 0.0.0.0:* 1433/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 1433/ntpd
我打开了我的networking连接,netstat给了我这个:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 4432/dnsmasq udp 0 0 127.0.1.1:53 0.0.0.0:* 4432/dnsmasq udp 0 0 0.0.0.0:123 0.0.0.0:* 4501/ntpdate udp6 0 0 :::123 :::* 4501/ntpdate
注意前两个是DNS,而不是ntp。 向右滚动以查看程序名称。
我等了一下,然后netstat给了我这个:
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 4432/dnsmasq udp 0 0 127.0.1.1:53 0.0.0.0:* 4432/dnsmasq udp 0 0 192.168.5.5:123 0.0.0.0:* 4542/ntpd udp 0 0 127.0.0.1:123 0.0.0.0:* 4542/ntpd udp 0 0 0.0.0.0:123 0.0.0.0:* 4542/ntpd
奇怪。 无论如何,它看起来像ntpdate是(暂时)给你udp6连接。 您必须使用sudo来查看PID和程序名称,否则这是非常具有误导性的。
(后来)啊,没关系,它看起来像你的确是ntp …