Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 (obfuscated) netstat listing shows nptd listening on the broadcast, local, LAN, and global addresses, for IPv4 and IPv6.

Why is ntpd so promiscuous?

share|improve this question
add comment

2 Answers

up vote 13 down vote accepted

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.

Note that normally ntpd should not be accepting packets on the wildcard addresses since there are a number of problems if you do so including sending return packets on a different address from the sender's requested address. DannyMayer - 27 Apr 2009

I think the main answer to your question is in the above comment here.

share|improve this answer
add comment

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):

 listen on address
         Specify a local IP address or a hostname the ntpd(8) daemon
         should listen on. If it appears multiple times, ntpd(8) will
         listen on each given address. If the exact string '*' is given as
         an address, ntpd(8) will listen on all local addresses. Other-
         wise, address can be followed by an asterisk ('*') and a UDP port
         number to listen on instead of the default 123. ntpd(8) does not
         listen on any address by default. For example:

               listen on *
               listen on 127.0.0.1
               listen on ::1

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)

share|improve this answer
1  
Feliz Ano Novo! –  Iain Jan 3 '13 at 15:03
1  
I don't think this really answers the question. I think the question is basically asking why INADDR_ANY isn't being used like almost every other protocol. The article I link to in my answer seems to make it clear, that it is partly a security feature, and partly the way the protocol is design to expect replies on port 123. –  Zoredache Jan 3 '13 at 18:44
    
This is very useful information that I wanted to know, and I thank you for it, but @Zoredache’s answer actually answers the question that I asked, so I’ve marked it as the answer. Upvotes all around, however. ;) –  Abraham Vegh Jan 3 '13 at 21:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.