Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
ntp-client does not sync the clock because DNS missing boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Wed Jul 13, 2016 10:25 am    Post subject: ntp-client does not sync the clock because DNS missing boot Reply with quote

Can someone give me a hint / fix on how to fix the ntp-client startup script please?

I prefer a fix when my dns / ip-address gets renewed / changed everytime ntp-client is run after maybe ping to the ntp-client succeeded.

Wish: Ntp-client checks for a valid internet connection, syncs the clock once, sets the hwclock, after it has finished, it stops itself and frees the used up memory. @ every boot of the box.

Sorry for the rant, a bit detail explanation with my personal opinion.

Code:
ASUS-G75VW roman # /etc/init.d/ntp-client restart
 * Setting clock via the NTP client 'ntpdate' ...                                                                                                                     [ ok ]
ASUS-G75VW roman # uptime
 12:13:04 up  2:38,  3 users,  load average: 0,49, 0,62, 0,65


I assume when I have read it correctly, that my box was over 2 hours 38 min awake and the clock was still not corrected?

My notebook is connected via wireless lan to my adsl modem. Because of some delays during bootup and there are no valid dns, the ntp-client shipped script fails and do not attempt to resync

Gentoo wiki recommendations are also not working, basically useless

Quote:
ASUS-G75VW roman # cat /etc/ntp.conf
# NOTES:
# DHCP clients can append or replace NTP configuration files.
# You should consult your DHCP client documentation about its
# default behaviour and how to change it.

# Name of the servers ntpd should sync with
# Please respect the access policy as stated by the responsible person.
#server ntp.example.tld iburst

# Common pool for random people
#server pool.ntp.org

# Pools for Gentoo users
server 0.gentoo.pool.ntp.org
server 1.gentoo.pool.ntp.org
server 2.gentoo.pool.ntp.org
server 3.gentoo.pool.ntp.org

##
# A list of available servers can be found here:
# http://www.pool.ntp.org/
# http://www.pool.ntp.org/#use
# A good way to get servers for your machine is:
# netselect -s 3 pool.ntp.org
##

# you should not need to modify the following paths
driftfile /var/lib/ntp/ntp.drift

#server ntplocal.example.com prefer
#server timeserver.example.org

# Warning: Using default NTP settings will leave your NTP
# server accessible to all hosts on the Internet.

# If you want to deny all machines (including your own)
# from accessing the NTP server, uncomment:
restrict default ignore


# Default configuration:
# - Allow only time queries, at a limited rate, sending KoD when in excess.
# - Allow all local queries (IPv4, IPv6)
restrict default nomodify nopeer noquery limited kod
restrict 127.0.0.1
restrict [::1]


# To allow machines within your network to synchronize
# their clocks with your server, but ensure they are
# not allowed to configure the server or used as peers
# to synchronize against, uncomment this line.
#
#restrict 192.168.0.0 mask 255.255.255.0 nomodify nopeer notrap

server 127.127.1.0
fudge 127.127.1.0 stratum 10

disable monitor


Code:
ASUS-G75VW roman # qlist -Iv net-misc/ntp
net-misc/ntp-4.2.8_p8
ASUS-G75VW roman # rc-update show|grep ntp
           ntp-client |      default                                 
ASUS-G75VW roman # emerge -pv ntp

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] net-misc/ntp-4.2.8_p8::gentoo  USE="ssl threads -caps -debug -ipv6 -libressl -openntpd -parse-clocks -readline -samba (-selinux) -snmp -vim-syntax -zeroconf" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB
ASUS-G75VW roman #


What annoys me is: I have set the ntp-client in my default runlevel. I would expect that the shipped scripts would at least force ntp-client to sync, and when the dns, lets rephrase it more easily, when my ip address / mask whatever ... is changed ntp is also forced.
It is definitely not.

In my eyes it is broken, but I am quite sure some will tell me, its my setup, whatever.

In short, ntp does not sync itself. Regardless fora reasonable time 2.5 hours is a reasonable time.

--

I have also an issue with dhcp because it overwrote my resolv.conf. I fixed that with setting the i flag wth chattr on resolv.conf

--

I also do not get the point when I add a service to rc-update, it should at least do something or work.

snip from messages after i manually restarted the service

Quote:
Jul 13 12:12:52 ASUS-G75VW ntpdate[9380]: step time server 131.130.251.107 offset 269.999538 sec


I have no idea why my notebook, whcih is always on the juice, battery or ac-power, it has always juice, has such a drift for a few months. ...

--

I remember when I used windows, 10 years ago, those time server forced to correct the hwclock.
hwclock tells me the time of my box.

Why can not we have that feature on, as in windows, to correct the hardware clock too?

--

I am qutie sure these issues do not exists on bigger networks, where you have 24h / 7 days a week a server alive and therfore you always have a valid dns with valid ntp server running. For lets call it dial up connections, could be when you are not picky, the provided shipped script is useless.

e.g.

https://forums.gentoo.org/viewtopic-p-6182060.html?sid=8ff21b26d91087f4ffe3f2a806993b3f

Quote:
From my point of view it seems like the wireless connection isn't established in time during boot and ntp-client runs into timeout. How could I change the timeout setting of ntp-client?


...

I have not dug deeper, there were a few other posts.

In short known issue. I want a proper fix, not a hack
Back to top
View user's profile Send private message
Syl20
l33t
l33t


Joined: 04 Aug 2005
Posts: 619
Location: France

PostPosted: Wed Jul 13, 2016 4:11 pm    Post subject: Reply with quote

I don't really understand what you want...

The ntp-client "service" (I don't think it is) just calls ntpdate, and exits. Period. rc-status shows it stopped. That means the clock is only synced once, on boot. To keep your clock synced everytime, you should enable the ntpd service, or add a ntpdate cron job.

If you want to sync your hardware clock, have a look on /etc/conf.d/hwclock.

If you need more features, perhaps it's time to write your own startup script ?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54237
Location: 56N 3W

PostPosted: Wed Jul 13, 2016 5:01 pm    Post subject: Reply with quote

tw04l124,

Quote:
I have also an issue with dhcp because it overwrote my resolv.conf. I fixed that with setting the i flag wth chattr on resolv.conf

That works but its not the way dhcpcd is designed to operate.

By design, dhcpcd does everything it possibly can automatically.
It has a set of no* flags to turn off individual things you would rather manage yourself. The man page is worth a read but less /usr/share/doc/netifrc-0.3.1/net.example.bz2
is a better source of information as its full of examples.

Things that need networking will not start until networking is considered to be 'up'. What that means is user definable.
See /etc/rc.conf.

You will nee do do some reading, or some trial and error, as some versions of openrc include the lo interface and some don't.
If lo.net alone satisfies what is needed for networking to be considered 'up' then ntp-client will fail.

As others have pointed out, ntp-client is run once, to do a large step correction to the system time, ntpd fine tunes the clock on a regular basis to keep it correct.
You may need both. ntpd will exit if the error is bigger that about 20 min.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Jul 23, 2016 12:40 pm    Post subject: Reply with quote

Syl20 wrote:


The ntp-client "service" (I don't think it is) just calls ntpdate, and exits. Period. rc-status shows it stopped. That means the clock is only synced once, on boot. To keep your clock synced everytime, you should enable the ntpd service, or add a ntpdate cron job.


Exactly. Gentoo shipped script is broken by design.

restart or start of the script seems to just run once and not keep it as deamon which i expect from ntp service.

I think I already stated enough already why it is broken

Script does not check for availability of the network. Means the outside is reachable. E.g. check with ping 4.4.4.4 or the ntp server itself.

SCript does not invoke itself after the network node is changed. Means changed settings to the network adapter

--

What I mean was to state why I think the shipped script is crap, not well designed. And I tried to explain it with my own words and give examples why.

--

I tried the other ntp pacakges which are in the tree, but they do exactly nothing.

I am not in the mood, becuase some idiotic programmer thought of so many possibliites. to read tons of man-pages and fiddle around with config files, to just sync the clock.

EAsy workaround as of now

Code:
 /etc/init.d/ntp-client restart;emerge --sync;emerge -av --update --keep-going --deep -N world


Which is enough because the box should be updated anyway regularly.

And no I am not a friend of aliases. I want to see what is done

--

Regarding windows 98, at least for sure windows 2000, was able to correct the hardware clock, sync the clock itself without much intervention.

--

Expected behaviour:

when the service is added to a rc runlevel. it should correct the clock and the hardware clock itself when the network node is changed. It does not hurt to sync the clock when the network address is renewed by e.g. dhcpcd, the user, ... ...
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sat Jul 23, 2016 12:47 pm    Post subject: Reply with quote

AFAIK net-misc/ntp provides both, ntp-client and ntpd. The first one corrects the clock at startup and exits, the second one keeps the clock correct. It is up to you to set it up properly.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Jul 23, 2016 12:53 pm    Post subject: Reply with quote

NeddySeagoon wrote:
tw04l124,

Quote:
I have also an issue with dhcp because it overwrote my resolv.conf. I fixed that with setting the i flag wth chattr on resolv.conf

That works but its not the way dhcpcd is designed to operate.


It is broken by design too, or I was just unable to find a way after reading pages over pages on how to get dhcpcd working.

The provided dns servers from the adsl2 modem are just unresponsive. WEbpages opens with a big delay in any browser installed. Its a DNS issue, because the DNS server can not handle the requrest in a timely fashion.

Code:
ASUS-G75VW roman # equery y dhcpcd
Keywords for net-misc/dhcpcd:
             |                                 |   u   | 
             | a a         p s     a   n r     |   n   | 
             | l m   h i   p p   m r m i i s   | e u s | r
             | p d a p a p c a x i m 6 o s 3   | a s l | e
             | h 6 r p 6 p 6 r 8 p 6 8 s c 9 s | p e o | p
             | a 4 m a 4 c 4 c 6 s 4 k 2 v 0 h | i d t | o
-------------+---------------------------------+-------+-------
   6.10.1    | + + + + + + + + + ~ ~ o o o ~ ~ | 5 o 0 | gentoo
   6.10.2    | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ o o o ~ ~ | 6 #   | gentoo
[I]6.10.3    | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ o o o ~ ~ | 6 #   | gentoo
   6.11.0    | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ o o o ~ ~ | 6 #   | gentoo
   6.11.1    | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ o o o ~ ~ | 6 #   | gentoo
   6.11.1-r1 | ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ o o o ~ ~ | 6 o   | gentoo
     9999    | o o o o o o o o o o o o o o o o | 6 o   | gentoo


Sadly any higher dhcpcd breaks functionality.
Means:

I install a higher dhcpcd, and the old config and the new config does not work anymore.

No DNS Aquired from MY ADSL2 modem, no wifi network stuff exchanged via wpa_supplicant and dns and ADSL2 modem.

workaround:
hardmask it.

---

I try to keep the technical aspects as much out as possible. Else some smart guy will show up and tells me how stuff works because its his profession (I think about 4-5 guys here ..).

I am well aware what DNS / DHCP and other stuff does, in the principles. Thats enough to understand the principles. I am not interested in knowing the full details of any software piece out there in the world. That is not my scope.

--

Summary / Expected behaviour

eudev + newest dhcpcd in portage tree + wpa_supplicant + ADSL2 modem with wifi functionality

Consider custom dns servers provided with /etc/resolv.conf as it used to be in the old days, and possible too
aquire network node data to be able to establish a successful connection with the www
(aquire ip adress somewhere in 10.0.0.x range, subnetmask, gateway, establish encrypted wifi connection with wpa_supplicant; works well with eudev)
withlist: sync the node time; should be all the duty of the service called net or network of rc-update
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Jul 23, 2016 1:03 pm    Post subject: Reply with quote

Jaglover wrote:
AFAIK net-misc/ntp provides both, ntp-client and ntpd. The first one corrects the clock at startup and exits, the second one keeps the clock correct. It is up to you to set it up properly.


Agree

Code:
^[[AJul 23 14:56:08 ASUS-G75VW ntpd[21811]: ntpd 4.2.8p8@1.3265-o Mon Jul 11 16:28:49 UTC 2016 (1): Starting
Jul 23 14:56:08 ASUS-G75VW ntpd[21811]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: proto: precision = 0.108 usec (-23)
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: restrict: ignoring line 47, address/host '[::1]' unusable.
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: restrict: 'monitor' cannot be disabled while 'limited' is enabled
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: Listen and drop on 0 v4wildcard 0.0.0.0:123
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: Listen normally on 1 lo 127.0.0.1:123
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: Listen normally on 2 wlan0 10.0.0.2:123
Jul 23 14:56:08 ASUS-G75VW ntpd[21814]: Listening on routing socket on fd #19 for interface updates


Code:
ASUS-G75VW roman # /etc/init.d/ntpd start
 * Starting ntpd ...   



Seems my fault to comprehend.

MAkes sense now, but ntp-client should not be able to be added to rc-update
ntp-client restart / start should point to ntpd

Of course the unix guys will say, look deamon => ntp daemon => ntpd => should be used, thats it, its obvious now
client ... just client. SHould not reside in /etc/init.d/ntp-client => belongs to /bin or /sbin

well but with these days software which do not keep the old structures properly, I may forgot to check for ntpd, or just overlooked it.
The root cause can not be determined anymore ...

I will adapt my box and report back.

--

Thanks for the feedback
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sat Jul 23, 2016 1:04 pm    Post subject: Reply with quote

Everything is broken by design? DHCP client can be fine tuned to set only parameters you want. You can exclude DNS if you wish. Again, it is up to you to set it up properly. But first you should ask yourself whether you need DHCP or not. You may do better with static configuration.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum