On 2/8/22, Greg Wooledge <g...@wooledge.org> wrote: > On Tue, Feb 08, 2022 at 02:43:02PM -0500, Lee wrote: >> How to tell systemd to leave the ntpd config alone? > > What makes you think the two are connected in any way?
$ grep "Network Time Service" syslog Feb 6 12:06:48 spot systemd[1]: Stopping Network Time Service... Feb 6 12:06:48 spot systemd[1]: Stopped Network Time Service. Feb 6 12:06:48 spot systemd[1]: Starting Network Time Service... Feb 6 12:06:48 spot systemd[1]: Started Network Time Service. Feb 6 12:09:25 spot systemd[1]: Stopping Network Time Service... Feb 6 12:09:25 spot systemd[1]: Stopped Network Time Service. Feb 6 12:09:25 spot systemd[1]: Starting Network Time Service... Feb 6 12:09:25 spot systemd[1]: Started Network Time Service. Feb 6 12:22:53 spot systemd[1]: Stopping Network Time Service... Feb 6 12:22:53 spot systemd[1]: Stopped Network Time Service. Feb 6 12:22:53 spot systemd[1]: Starting Network Time Service... Feb 6 12:22:53 spot systemd[1]: Started Network Time Service. ... etc every time I connect or disconnect from a wifi network. Right after systemd[1]: Starting Network Time Service... comes ntpd[43320]: ntpd 4.2.8p15@1.3728-o Wed Sep 23 11:46:38 UTC 2020 (1): Starting ntpd[43320]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -c /run/ntp.conf.dhcp -u 117:124 /run/ntp.conf.dhcp starts off with # This file was copied from /etc/ntp.conf with the server options changed # to reflect the information sent by the DHCP server. Any changes made # here will be lost at the next DHCP event. Edit /etc/ntp.conf instead. # NTP server entries received from DHCP server server <my ip address> iburst <my ip address> is the NTP server for the local network, so replacing all the pool and server addresses in the ntp config with it's own ip address is a problem. My first thought was telling the machine to ignore the NTP server address handed out via DHCP. Maybe there's a way to do that, but I couldn't figure out how :( 2nd thought was telling the DHCP server to not hand out an NTP server address to this one machine, but that's another damnifi know how to. > Under bullseye, if the ntp package (which supplies the ntpd program) is > installed, then systemd-timesyncd is removed. The two packages will not > coexist. > > Under some older versions of Debian (I'm not sure when it changed exactly), > they can coexist, but the systemd-timesyncd service is configured not to > run if /usr/sbin/ntpd exists and is executable. > > Either way, if ntp(d) is installed, systemd will not do anything regarding > time synchronization or NTP. The syslog messages say otherwise. >> I tried changing /etc/dhcp/dhclient.conf to request just >> request subnet-mask, broadcast-address, routers, >> interface-mtu, >> rfc3442-classless-static-routes ; >> >> and systemd still restarted ntpd with only the dhcp supplied ntp >> server address ... which is this machine, so all the configured ntp >> servers went away :( > > This is too vague. What are you actually seeing? This machine is the ntp server for other machines on the local network. I have multiple wifi networks, so I'd prefer to keep the wifi connection using DHCP. The problem seems to be 1. the DHCP server hands out an NTP server as part of the info 2. this machine does not ignore the ntp server info in the dhcp reply 3. systemd restarts ntpd with a "-c /run/ntp.conf.dhcp" parameter. That file has only the one dhcp supplied ntp server in the config. Normally 'ntpq -p' shows lots of servers. After connecting to the wifi network, and before changing /usr/lib/ntp/ntp-systemd-wrapper, an 'ntpq -p' showed only one server, this machine, and the status was .. I don't remember exactly what, but something clearly broken For all the other machines on the local net that are using DHCP, the default DHCP request info in /etc/dhcp/dhclient.conf is good. But this machine is the DNS and NTP server, so the only DHCP info it should accept is the ip address, mask & default gateway. But I don't know how to make that happen :( > unicorn:~$ ps auxw | grep ntpd > ntp 758 0.0 0.0 74696 3896 ? Ssl Feb04 0:14 > /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 107:112 > greg 290127 0.0 0.0 6244 2404 pts/0 S+ 15:04 0:00 grep > ntpd After connecting to a wifi network the ntpd process had "-c /run/ntp.conf.dhcp" after the "-g" > The ntpd program (service) isn't started with an NTP server address as > an argument. The configuration is all in files. yes, the file is /run/ntp.conf.dhcp It starts off with # This file was copied from /etc/ntp.conf with the server options changed # to reflect the information sent by the DHCP server. I don't know how to tell the DHCP server to _not_ include the ntp server address in the dhcp info sent to just this one machine. The DHCP request supposedly uses /etc/dhcp/dhclient.conf to decide what to request from the DHCP server. But I couldn't figure out how to get and/or accept _only_ the ip address, mask & default gateway from the DHCP server. > unicorn:~$ grep -e ^server -e ^pool /etc/ntp.conf > pool 0.debian.pool.ntp.org iburst > pool 1.debian.pool.ntp.org iburst > pool 2.debian.pool.ntp.org iburst > pool 3.debian.pool.ntp.org iburst > > Are you claiming that systemd has somehow modified your /etc/ntp.conf > file? I'm claiming that systemd restarts the ntp daemon with a "-c /run/ntp.conf.dhcp" option >What change did it make? $ head /run/ntp.conf.dhcp # This file was copied from /etc/ntp.conf with the server options changed # to reflect the information sent by the DHCP server. Any changes made # here will be lost at the next DHCP event. Edit /etc/ntp.conf instead. # NTP server entries received from DHCP server server <my ip address> iburst # /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help driftfile /var/lib/ntp/ntp.drift In other words, all the "server" and "pool" lines in my /etc/ntp.conf have been replaced with the one ntp server address handed out by dhcp >> I then tried telling network manager to just get an ip address & >> subnet mask from dhcp. And still systemd fucked up the ntpd config >> >> What finally worked was editing /usr/lib/ntp/ntp-systemd-wrapper to >> remove ' NTPD_OPTS="$NTPD_OPTS -u $UGID" ' > > Huh? You're saying that removing the "-u $UGID" option made it "work"? > And that it "didn't work" with -u being passed? I changed this bit in /usr/lib/ntp/ntp-systemd-wrapper if [ -e /run/ntp.conf.dhcp ]; then NTPD_OPTS="$NTPD_OPTS -c /run/ntp.conf.dhcp" fi to if [ 0 -eq 1 ]; then if [ -e /run/ntp.conf.dhcp ]; then NTPD_OPTS="$NTPD_OPTS -c /run/ntp.conf.dhcp" fi fi So systemd is still restarting the ntp daemon, but at least it's not giving it a broken config to use any more. > What errors were you getting in your logs? I didn't notice any errors in the logs. I was "playing along at home" with a thread about troubleshooting ntp & the suggestion was to do an 'ntpq -p' .. which I did and then started cursing when I saw just the one server listed that clearly wasn't working. Thanks Lee