I’ve noticed this for a while, and it’s never made any sense to me:
Why does ntpd
need to listen on so many addresses?
For example, a Debian machine:
$ netstat Proto Local Address Foreign Address Program name udp 0.0.0.0:123 0.0.0.0:* ntpd udp 127.0.0.1:123 0.0.0.0:* ntpd udp [LAN]:123 0.0.0.0:* ntpd udp [IPv4]:123 0.0.0.0:* ntpd udp6 :::123 :::* ntpd udp6 ::1:123 :::* ntpd udp6 [link-local] :::* ntpd udp6 [IPv6] :::* ntpd
This (redacted) netstat
listing shows nptd
listening on the broadcast, local, LAN, and global addresses, for IPv4 and IPv6.
Why is ntpd
so promiscuous?
It is not promiscuous at all. It's just binding to the interface IP addresses and localhost, both on ipv4 and ipv6 protocols. If you think it should not be listening to some of those, just change the
listen
config as explained in the manual (this may be for a different version that you are using):In some other versions you will need to change the options to the
ntpd
daemon itself to change on what protocols/interfaces to listen (options like-4
,-6
,-I
)From my reading of this page, it appears that ntp doesn't use the INADDR_ANY
0.0.0.0
address exclusively partly for security reasons, and partly for authentication reasons.First port 123, is below 1024, and so is considered a privileged port, and only root can bind to that port. Ntp is typically set to drop privileges after it is started. From what I understand from the mail lists, and the article once the privileges are dropped can't open a socket to reply from correct source port of 123, so ntp opens up sockets for every assigned address before it drops privileges.
From what I have read some of the authentication mechanisms for ntp basically require that the source and destination port be 123, and nothing else.
The matter isn't entirely clear. See the section about the wildcard address
0.0.0.0
, it is opened by ntpd for some reason, but from the comments should never actually be used, except possible in some special rare cases, that the devs aren't entirely sure about, but, they don't want to remove the socket, just in case they break things.I think the main answer to your question is in the above comment here.