Solved ntpd only local socket

Hi,

I am not able to bind ntpd service to unix socket or loopback interface via rc.conf
Code:
ntpd_enable="YES"
ntpd_flags="-p /var/run/ntpd.sock"

this error is generated

Code:
Starting ntpd.
ntpd error:  only one pidfile option allowed
ntpd - NTP daemon program - Ver. 4.2.8p17
Usage:  ntpd [ -<flag> [<val>] | --<name>[{=| }<val>] ]... \
            [ <server1> ... <serverN> ]
Try 'ntpd --help' for more information.
/etc/rc.d/ntpd: WARNING: failed to start ntpd

running the ntpd with no flags works as expected but the socket is exposed outside, netstat -an | grep 123

Code:
udp4       0      0 *.123                  *.*
udp6       0      0 *.123                  *.*

Thanks
 
Last edited by a moderator:
I think you want to specify a listening port in /etc/ntp.conf, eg
Code:
interface listen 127.0.0.1
The -p flag is for specifying the pid file path, which is already done in /etc/rc.d/ntpd.
 
I added interface listen 127.0.0.1, and restarted the ntpd service, however it did not help
Code:
netstat -an | grep 123
udp4       0      0 127.0.0.1.123          *.*
udp6       0      0 ::1.123                *.*
udp4       0      0 *.123                  *.*
udp6       0      0 *.123                  *.*
 
Although it may appear to listen for remote connections, the restrict in ntp.conf limits this.
 
edit /etc/ntp.conf and add the following at the bottom of the file.

interface ignore wildcard
interface listen 127.0.0.1
and for ipv6 if you want
interface listen ::1

Note: "ntpd_flags= -I lo0" flag in /etc/rc.conf will overwrite the interface rules in ntp.conf so you must remove it.

"interface/nic rules are not allowed with --interface (-I) or --novirtualips (-L)%s"

even if you leave 0.0.0.0:123 the restrict 127.0.0.1 which is default in /etc/ntp.conf will drop any connection on all interfaces except 127.0.0.1

 
Back
Top