Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
If using ntpd, do I also need ntp-client?
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
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1187
Location: Edinburgh, UK

PostPosted: Sun Oct 31, 2010 12:37 pm    Post subject: If using ntpd, do I also need ntp-client? Reply with quote

Hi,

I did find one old thread about this, but it's from 2005 and I'm afraid the info might be out of date as the advice there didn't seem to match things on my system now.

I have two laptops and a server on my home network. Currently they all use ntp-client with NTPCLIENT_CMD="sntp" for setting their clocks. I thought I'd be a good netizen and set up ntpd on the server for the other machines to use rather than bothering public servers every boot.

What I'm not clear on is this: if ntpd is running on the server, should I still be running ntp-client (with NTPCLIENT_CMD="ntpd") on the same machine in order to update the clock? Or is ntpd doing this already?

Because it mentions it in /etc/conf.d/ntp-client, I tried configuring it to use NTPCLIENT_CMD="ntpd" but after various config attempts ntp-client won't start. That's mainly why I think I probably shouldn't be running both.

Can anyone clarify this? I was sure I remembered a good page in the Handbook that explained all this, but now I can't find it :(

Thanks in advance.
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


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

PostPosted: Sun Oct 31, 2010 1:11 pm    Post subject: Reply with quote

AFAIK ntpd is client and server. BTW, there is lots more traffic than getting correct time at boot.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3809
Location: Hamburg

PostPosted: Sun Oct 31, 2010 1:17 pm    Post subject: Reply with quote

ntpd is slewing the clock if if the time difference is below a given limit. Any time differences greater that limit aren't handled by ntpd. IN such a case an explicitly time set is necessary (as done by ntp-client).
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1187
Location: Edinburgh, UK

PostPosted: Sun Oct 31, 2010 1:44 pm    Post subject: Reply with quote

Jaglover wrote:
AFAIK ntpd is client and server. BTW, there is lots more traffic than getting correct time at boot.


I think I see what you mean, having found a couple of other pages ( Wiki and Bug added a bit more to my understanding.

I have a couple of problems then.

(A) ntpd is contacting the external servers so frequently that it outweighs the benefit of not having the two other machines do so every boot (even if this is at least a couple of times a day between them). Can I adjust the frequency of syncing to a much lower level to offset this? It obviously needs doing occasionally for an always-on machine, but I'd imagine once a day or even less would be adequate.

(B) When the laptops go travelling, they can't use the local ntpd, so I have to leave at least one external server in the list for such occasions. But as far as I can tell, even when the IP of the local ntpd is available, sntp will still use the others as well, so nothing is gained! Two question here: Does sntp (or any of the other client options) *need* to use more than one server? And if not, can I somehow make it always try the local IP first, then fall back to the external ones? (That's how I thought it would work to start with.)

Also, after reading the argument in that bugreport, I'm not sure whether sntp is even working right now. There seems no definitive answer!
Back to top
View user's profile Send private message
Jaglover
Watchman
Watchman


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

PostPosted: Sun Oct 31, 2010 11:30 pm    Post subject: Reply with quote

A - The interval will increase significantly once ntpd gets the clock under control and learns the drift.

B - I have no definite answer, I'm running ntpd in my router and all computers on my LAN use it as source.
Back to top
View user's profile Send private message
Havin_it
Veteran
Veteran


Joined: 17 Jul 2005
Posts: 1187
Location: Edinburgh, UK

PostPosted: Mon Nov 01, 2010 9:06 am    Post subject: Reply with quote

Can't believe I spent most of yesterday messing about with this - NTP's documentation is very dense, not a fun read at all.

For the client machines, I decided to use NTPCLIENT_CMD="ntpd" as this seems to be the upstream-approved method now (and neither ntpdate or sntp seem to work properly at boot). However, to achieve the host selection I seek I had to get a bit creative. I made a copy of ntp.conf called ntp-local.conf, where the local server replaces the pool.gentoo.ntp.org servers. Then I made this script called "getntpconf":
Code:
#!/bin/sh

if ping -w1 <LOCALSERVER> &>/dev/null; then
        echo /etc/ntp-local.conf
else
        echo /etc/ntp.conf
fi


Then I change edit the NTPCLIENT_OPTS line in /etc/conf.d/ntp-client to
Code:
NTPCLIENT_OPTS="-g -q -c `/usr/local/bin/getntpconf`"


I always wondered if you could use backticked commands in conf.d files, and it appears you can, so problem solved :)

What would be interesting would be to examine how much traffic ntpd generates. Is there any way I can monitor the program (or the port) to find this out?
Back to top
View user's profile Send private message
Veldrin
Veteran
Veteran


Joined: 27 Jul 2004
Posts: 1945
Location: Zurich, Switzerland

PostPosted: Mon Nov 01, 2010 11:28 am    Post subject: Reply with quote

Quote:
What would be interesting would be to examine how much traffic ntpd generates. Is there any way I can monitor the program (or the port) to find this out?
ntp uses port 123 (tcp and udp). you can use the usual suspects (tcpdump, wireshark) to analyse traffic.
IIRC the taffic is rather small.

cheers
V.
Back to top
View user's profile Send private message
cwr
Veteran
Veteran


Joined: 17 Dec 2005
Posts: 1969

PostPosted: Mon Nov 01, 2010 7:46 pm    Post subject: Reply with quote

Below is the ntp.conf I use on my laptop - I check the time by hand, not automatically, on this
machine (using ntpd -q). Then after rebooting with an ntpd server running it acts as a reference
source for the other machines on my intranet.

# NOTES:
# - you should only have to update the server line below
# - if you start getting lines like 'restrict' and 'fudge'
# and you didnt add them, AND you run dhcpcd on your
# network interfaces, be sure to add '-Y -N' to the
# dhcpcd_ethX variables in /etc/conf.d/net

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

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

# Pools for UK users.
server 0.uk.pool.ntp.org
server 1.uk.pool.ntp.org
server 2.uk.pool.ntp.org
server 3.uk.pool.ntp.org
server uk.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
##

# Internet time servers.
#server ntp2a.mcc.ac.uk
#server ntp2.strath.ac.uk
# Use this on local network devices other than the T23.
#server 193.237.32.199

# This says that the hardware clock is a (default level 5)
# reference. The pseudo-IP address is the index of a particular
# type of clock in the NTP source code. (See refclock.html)
#server 127.127.1.0 prefer
# Set clock-specific options.
#fudge 127.127.1.0 stratum 10

# You should not need to modify the following paths.

# (Drift checks the system clock against the reference clock.)
driftfile /var/lib/ntp/ntp.drift

# 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

# To deny other machines from changing the
# configuration but allow localhost:
restrict default nomodify nopeer
restrict 127.0.0.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
# Used by VirtualBox images.
#restrict 193.237.32.0 mask 255.255.255.192 nomodify nopeer notrap

# eof
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