[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: systemd/dhcp v. ntpd



On 2/9/22, Reco <recoverym4n@enotuniq.net> wrote:
> 	Hi.
>
> On Wed, Feb 09, 2022 at 09:05:51AM -0500, Lee wrote:
>> On 2/8/22, Greg Wooledge <greg@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.
>
> Or it could mean that dhclient hook merely asks systemd to restart ntpd
> service. See /etc/dhcp/dhclient-exit-hooks.d/ntp.

That's certainly better :)

mkdir /etc/dhcp/dhclient-exit-hooks.d.NOT
mv  /etc/dhcp/dhclient-exit-hooks.d/ntp  /etc/dhcp/dhclient-exit-hooks.d.NOT/ntp

disconnect / connect wifi and 'ntpq -p' still shows most servers with
a reach value of 377
(ie. ntpd isn't being restarted :)

>> 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 :(
>
> supercede ntp-servers "..." in dhclient.conf should do it for you.
>
> The option was helpfully provided by dhclient.conf(5).

I tried not giving it a value - ie
supersede ntp-servers ;

didn't work.  Apparently one _has_ to give it a value.

>> >> 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 :(
>
> And that merely stopped dhclient from asking DHCP server to provide
> "ntp-server" option. What it cannot stop is DHCP server providing
> "ntp-server" option anyway.
>
> ISC dhclient simply lacks the option to ignore certain options in DHCP
> reply. It can supercede them though.

The way I read the man page, supercede requires a value.  I can't just
say ignore what the DHCP server gives me, I have to say use <this>
instead of what the DHCP server gives me ... and there is no <this>
value, it's several pool & server lines that I don't want replaced.

>> >> 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?
>
> Changing the contents of /etc/dhcp/dhclient-exit-hooks.d/ntp would make
> it more friendly for the purpose of the future updates.

Changing it or moving it to another, clearly not supposed to be
invoked, directory?

Either way - I agree, changing /etc/dhcp/dhclient-exit-hooks.d/ntp is
the better method.

Thanks
Lee


Reply to: