NavigationUser loginSpam?See spam posts on this site? If so, please don't reply to the spam! Instead, just report the URL to the webmaster. |
Etch as a NTP ServerIt would appear that ntp-server has been deprecated in Etch yet updated HowTo documentation is scarce. In ubuntu, I had no problems to get it to act as a NTP server and serve time to all my clients. I initially threw ubuntu on a really old laptop as a proof of concept and now want to migrate everything over to a new fast desktop machine. Could/would someone please point me toward pertinent NTP documentation? TIA, Les |
Etch as a NTP Server
Oh, forgot to mention what I have installed on ubuntu. I had taken the shotgun approach and installed all of the following:
ntp
ntpdate
ntp-server
ntp-simple
I do believe it is SNTP that is being used by my clients (routers, switches, APs, etc).
Etch as a NTP Server
NTP3 is being deprecated and NTP4 is the current version. For all the horrible details see:
http://www.ntp.org/
All functions (client, server, set clock etc) have been put into one program and you now have less control of the stratum reporting (mostly internal now). NTP has basically moved from a client/server to a peer structure system. If you want to do your own timekeeping, make sure you have access to multiple low-stratum peers or else connect a GPS receiver to improve your stratum rating.
I had 2 computers, A and B - B can talk to A and A can talk to the internet (sometimes). When A is disconnected from the internet even for periods of a few minutes its stratum degrades pretty fast and B refuses to sync from it; I could not get A and B to cooperate and maintain time in the absence of the internet or a GPS receiver. I'm too lazy to figure it all out so I just attached a GPS receiver.
Etch as a NTP Server
OUCH! OK, maybe I should have put greater emphasis on the S in SNTP. Maybe if I put into context, my objective and my existing infrastructure. For this particular network I'm not running a multi-server web hosting service with complex application servers that need high accuracy. (We do, on other networks and have a GPS timesource but that is another story.)
I run a complimentary (not for profit) internet hotspot that is totally separate from our other business and process control networks. It is just a small network covering two kilometres of industrial complex. Aside from this Debian Etch, there is no other linux that needs to timesync. I need only SNTP to sync the time on WiFi APs so that the log timestamps are correct.
Eventually I hope to setup this box to receive and consolidate the AP's event logs. I'm exploring Nagios at the moment.
In comparing my Ubuntu proof-of-concept, I see in the GUI netstat, that it is listening on my 192.168.0.0 network on port 123 while Debian is not. How do I get Etch to do so?
TIA,
Les
Etch as a NTP Server
The quickest way is to look at the Ubuntu configuration file for ntpd.
Etch as a NTP Server
Well that's just not working for me. I never set or changed anything in /etc/ntp.conf on Ubuntu yet it happily serves up time. Not sure waddup widdat.
would it help to beg?
I just cannot make this work. I wonder now if I am too stupid to own a computer or something is broken in Etch?
nevermind
Got it sorted. Did the old Microsoft trick and uninstalled/reinstalled. Guess it's not just a Microsoft thing.
Dang, it's back
NTP worked after removing reinstalling until I rebooted. Now it's broken again. Remove/reinstall and it works again.
Anyone have an idea what is going on?
Dang, it's back
So, I'm thinking the way NTP starts after install is different then how it starts on boot. THe following is the contents of /etc/rc2.d/S23ntp:
#!/bin/sh
### BEGIN INIT INFO
# Provides: ntp
# Required-Start: $network $remote_fs $syslog
# Required-Stop: $network $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start NTP daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
. /lib/lsb/init-functions
NAME=ntp
DAEMON=/usr/sbin/ntpd
PIDFILE=/var/run/ntpd.pid
test -x $DAEMON || exit 5
if [ -r /etc/default/$NAME ]; then
. /etc/default/$NAME
fi
if [ -e /etc/ntp.conf.dhcp ]; then
NTPD_OPTS="$NTPD_OPTS -c /etc/ntp.conf.dhcp"
fi
RUNASUSER=ntp
UGID=$(getent passwd $RUNASUSER | cut -f 3,4 -d:) || true
case $1 in
start)
log_daemon_msg "Starting NTP server" "ntpd"
if [ -z "$UGID" ]; then
log_failure_msg "user \"$RUNASUSER\" does not exist"
exit 1
fi
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -- -p $PIDFILE -u $UGID $NTPD_OPTS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping NTP server" "ntpd"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
log_end_msg $?
rm -f $PIDFILE
;;
restart|force-reload)
$0 stop && sleep 2 && $0 start
;;
try-restart)
if $0 status >/dev/null; then
$0 restart
else
exit 0
fi
;;
reload)
exit 3
;;
status)
pidofproc -p $PIDFILE $DAEMON >/dev/null
status=$?
if [ $status -eq 0 ]; then
log_success_msg "NTP server is running."
else
log_failure_msg "NTP server is not running."
fi
exit $status
;;
*)
echo "Usage: $0 {start|stop|restart|try-restart|force-reload|status}"
exit 2
;;
esac
Ideas?
Etch as a NTP Server
You can look at the setup scripts; I can't remember where they are stored now - try looking in /var/lib/dpkg/info - they have the name (packagename).postinst
Perhaps ntpd runs as 'root' in one instance and as 'ntp' in another - in such a case you have to make sure that any hardware which ntp needs access to has permissions set appropriately. Did you try to start it by hand (/etc/init.d/ntp start) and have you checked the logs for messages about what's failing?
Etch as a NTP Server
OK, here is the post-install script:
#!/bin/sh
set -e
if [ "$1" = "configure" ]; then
adduser --system --quiet --group --no-create-home ntp || :
chown -R ntp:ntp /var/lib/ntp /var/log/ntpstats
# Make sure the previous daemon gets stopped. Versions up to and
# including 1:4.2.0a+stable-8.2 don't properly stop the daemon in
# case ntp-simple or ntp-refclock is removed before ntp-server:
# the binary is removed and the init script doesn't do a thing.
if [ -n "$2" ] && dpkg --compare-versions "$2" lt 1:4.2.0a+stable-9; then
if [ -x "/etc/init.d/ntp" ]; then
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d ntp stop
else
/etc/init.d/ntp stop
fi
fi
fi
# Disable configuration files of predecessor package.
if [ -n "$2" ] && dpkg --compare-versions "$2" le 1:4.2.2.p4+dfsg-1; then
for file in \
/etc/cron.daily/ntp-server \
/etc/cron.weekly/ntp-server \
/etc/init.d/ntp-server \
/etc/interfaces/if-up.d/ntp-server \
/etc/logcheck/ignore.d.server/ntp-server
do
if [ -f $file ]; then
mv -f $file $file.dpkg-old
fi
done
update-rc.d -f ntp-server remove
fi
fi
installinit_error() {
exit $?
}
# Automatically added by dh_installinit
if [ -x "/etc/init.d/ntp" ]; then
update-rc.d ntp defaults 23 >/dev/null
if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
invoke-rc.d ntp start || installinit_error
else
/etc/init.d/ntp start || installinit_error
fi
fi
# End automatically added section
Etch as a NTP Server
And the syslog entries showing the removal/reinstallation:
2882 debian1 auth-info 2007-04-10 17:09:01 CRON[16503]: (pam_unix) session opened for user root by (uid=0)
2883 debian1 cron-info 2007-04-10 17:09:01 /USR/SBIN/CRON[16504]: (root) CMD ( [ -d /var/lib/php4 ] && find /var/lib/php4/ -type f -cmin +$(/usr/lib/php4/maxlifetime) -print0 | xargs -r -0 rm)
2884 debian1 auth-info 2007-04-10 17:09:01 CRON[16503]: (pam_unix) session closed for user root
2888 debian1 daemon-notice 2007-04-10 17:16:21 ntpd[2624]: ntpd exiting on signal 15
2889 debian1 authpriv-info 2007-04-10 17:16:21 userdel[16919]: delete user `ntp'
2890 debian1 authpriv-info 2007-04-10 17:16:21 userdel[16919]: removed group `ntp' owned by `ntp'
2891 debian1 auth-info 2007-04-10 17:17:01 CRON[16955]: (pam_unix) session opened for user root by (uid=0)
2892 debian1 cron-info 2007-04-10 17:17:01 /USR/SBIN/CRON[16956]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
2893 debian1 auth-info 2007-04-10 17:17:01 CRON[16955]: (pam_unix) session closed for user root
2894 debian1 authpriv-info 2007-04-10 17:17:47 groupadd[17023]: new group: name=ntp, GID=114
2895 debian1 authpriv-info 2007-04-10 17:17:47 useradd[17024]: new user: name=ntp, UID=111, GID=114, home=/home/ntp, shell=/bin/false
2896 debian1 authpriv-info 2007-04-10 17:17:47 chage[17025]: changed password expiry for ntp
2897 debian1 daemon-notice 2007-04-10 17:17:47 ntpd[17050]: ntpd -o Sun Mar 4 13:21:35 UTC 2007 (1)
2898 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: precision = 1.000 usec
2899 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface wildcard, 0.0.0.0#123 Disabled
2900 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface wildcard, ::#123 Disabled
2901 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface lo, ::1#123 Enabled
2902 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface eth0, fe80::21a:4bff:feb5:819c#123 Enabled
2903 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface lo, 127.0.0.1#123 Enabled
2904 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: Listening on interface eth0, 192.168.2.20#123 Enabled
2905 debian1 daemon-info 2007-04-10 17:17:47 ntpd[17051]: kernel time sync status 0040
2906 debian1 daemon-info 2007-04-10 17:17:56 ntpd[17051]: synchronized to 216.46.5.9, stratum 3
Etch as a NTP Server
I rebooted this morning and looking at the boot sequence, it appears NTP starts before the ethernet interface does. Might this be the problem? If so, what might be the proper fix?
Apr 11 08:11:49 debian1 NetworkManager: Activation (eth0) Stage 3 of 5 (IP Configure Start) started...
Apr 11 08:11:50 debian1 NetworkManager: Activation (eth0) Beginning DHCP transaction.
Apr 11 08:11:51 debian1 NetworkManager: Activation (eth0) Stage 3 of 5 (IP Configure Start) complete.
Apr 11 08:11:51 debian1 NetworkManager: DHCP daemon state is now 12 (successfully started) for interface eth0
Apr 11 08:11:51 debian1 rpc.statd[2592]: Version 1.0.10 Starting
Apr 11 08:11:51 debian1 ntpd[2616]: ntpd -o Sun Mar 4 13:21:35 UTC 2007 (1)
Apr 11 08:11:51 debian1 ntpd[2617]: precision = 1.000 usec
Apr 11 08:11:51 debian1 ntpd[2617]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Apr 11 08:11:51 debian1 ntpd[2617]: Listening on interface wildcard, ::#123 Disabled
Apr 11 08:11:51 debian1 ntpd[2617]: Listening on interface lo, ::1#123 Enabled
Apr 11 08:11:51 debian1 ntpd[2617]: Listening on interface lo, 127.0.0.1#123 Enabled
Apr 11 08:11:51 debian1 ntpd[2617]: kernel time sync status 0040
Apr 11 08:11:51 debian1 ntpd[2617]: frequency initialized 90.872 PPM from /var/lib/ntp/ntp.drift
Apr 11 08:11:52 debian1 NetworkManager: DHCP daemon state is now 1 (starting) for interface eth0
Apr 11 08:11:52 debian1 anacron[2650]: Anacron 2.3 started on 2007-04-11
Apr 11 08:11:52 debian1 anacron[2650]: Normal exit (0 jobs run)
Apr 11 08:11:52 debian1 /usr/sbin/cron[2663]: (CRON) INFO (pidfile fd = 3)
Apr 11 08:11:52 debian1 /usr/sbin/cron[2664]: (CRON) STARTUP (fork ok)
Apr 11 08:11:52 debian1 /usr/sbin/cron[2664]: (CRON) INFO (Running @reboot jobs)
Apr 11 08:11:53 debian1 ntpd_initres[2626]: host name not found: 0.debian.pool.ntp.org
Apr 11 08:11:53 debian1 ntpd_initres[2626]: couldn't resolve `0.debian.pool.ntp.org', giving up on it
Apr 11 08:11:53 debian1 ntpd_initres[2626]: host name not found: 1.debian.pool.ntp.org
Apr 11 08:11:53 debian1 ntpd_initres[2626]: couldn't resolve `1.debian.pool.ntp.org', giving up on it
Apr 11 08:11:53 debian1 ntpd_initres[2626]: host name not found: 2.debian.pool.ntp.org
Apr 11 08:11:53 debian1 ntpd_initres[2626]: couldn't resolve `2.debian.pool.ntp.org', giving up on it
Apr 11 08:11:53 debian1 ntpd_initres[2626]: host name not found: 3.debian.pool.ntp.org
Apr 11 08:11:53 debian1 ntpd_initres[2626]: couldn't resolve `3.debian.pool.ntp.org', giving up on it
Apr 11 08:11:54 debian1 kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
Apr 11 08:11:56 debian1 dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Apr 11 08:11:56 debian1 dhclient: DHCPACK from 192.168.1.1
Apr 11 08:11:57 debian1 avahi-daemon[2452]: New relevant interface eth0.IPv4 for mDNS.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.20.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Registering new address record for 192.168.2.20 on eth0.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Withdrawing address record for 192.168.2.20 on eth0.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.2.20.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: iface.c: interface_mdns_mcast_join() called but no local address available.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Interface eth0.IPv4 no longer relevant for mDNS.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: New relevant interface eth0.IPv4 for mDNS.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.20.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Registering new address record for 192.168.2.20 on eth0.
Apr 11 08:11:57 debian1 NetworkManager: DHCP daemon state is now 4 (reboot) for interface eth0
Apr 11 08:11:57 debian1 NetworkManager: Activation (eth0) Stage 4 of 5 (IP Configure Get) scheduled...
Apr 11 08:11:57 debian1 NetworkManager: Activation (eth0) Stage 4 of 5 (IP Configure Get) started...
Apr 11 08:11:57 debian1 dhcdbd: message_handler: message handler not found under /com/redhat/dhcp/eth0 for sub-path eth0.dbus.get.host_name
Apr 11 08:11:57 debian1 dhcdbd: message_handler: message handler not found under /com/redhat/dhcp/eth0 for sub-path eth0.dbus.get.nis_domain
Apr 11 08:11:57 debian1 dhcdbd: message_handler: message handler not found under /com/redhat/dhcp/eth0 for sub-path eth0.dbus.get.nis_servers
Apr 11 08:11:57 debian1 NetworkManager: Retrieved the following IP4 configuration from the DHCP daemon:
Apr 11 08:11:57 debian1 NetworkManager: address 192.168.2.20
Apr 11 08:11:57 debian1 NetworkManager: netmask 255.255.0.0
Apr 11 08:11:57 debian1 NetworkManager: broadcast 192.168.255.255
Apr 11 08:11:57 debian1 NetworkManager: gateway 192.168.1.1
Apr 11 08:11:57 debian1 NetworkManager: nameserver 192.168.1.1
Apr 11 08:11:57 debian1 NetworkManager: domain name 'acihotspot.local'
Apr 11 08:11:57 debian1 NetworkManager: Activation (eth0) Stage 5 of 5 (IP Configure Commit) scheduled...
Apr 11 08:11:57 debian1 NetworkManager: Activation (eth0) Stage 4 of 5 (IP Configure Get) complete.
Apr 11 08:11:57 debian1 NetworkManager: Activation (eth0) Stage 5 of 5 (IP Configure Commit) started...
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Withdrawing address record for 192.168.2.20 on eth0.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.2.20.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: iface.c: interface_mdns_mcast_join() called but no local address available.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Interface eth0.IPv4 no longer relevant for mDNS.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: New relevant interface eth0.IPv4 for mDNS.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.2.20.
Apr 11 08:11:57 debian1 avahi-daemon[2452]: Registering new address record for 192.168.2.20 on eth0.
Apr 11 08:11:57 debian1 dhclient: bound to 192.168.2.20 -- renewal in 2785 seconds.
Apr 11 08:11:58 debian1 NetworkManager: Clearing nscd hosts cache.
Apr 11 08:11:58 debian1 NetworkManager: nm_spawn_process (): nm_spawn_process('/usr/sbin/nscd -i hosts'): could not spawn process. (Failed to execute child process "/usr/sbin/nscd" (No such file or directory))
Apr 11 08:11:58 debian1 NetworkManager: Activation (eth0) successful, device activated.
Apr 11 08:11:58 debian1 NetworkManager: Activation (eth0) Finish handler scheduled.
Apr 11 08:11:58 debian1 NetworkManager: Activation (eth0) Stage 5 of 5 (IP Configure Commit) complete.
Etch as a NTP Server
Dare I use the word "bug"? These guys did.
https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/90267
Possible Workaround...
I'd drop the package ntpdate, as it's irrelevent to what you're trying to do.
Then, make a file in the directory /etc/network/interfaces/ifup.d
call it ntpd for grins...
the file will read something like this:
--
#! /bin/sh
set -e
NTPD=/etc/init.d/ntpd
$NTPD restart
exit 0
--
Make the file you created executable by doing:
chmod a+x /etc/network/interfaces/ifup.d/ntpd
This should make ntpd restart after the interface comes up, and sync.
Try it out by simply doing:
ifdown eth0
ifup eth0
and check your log...
--
Jai yen
Possible Workaround...
I've already removed ntpdate as it did not help. From what I read it is a client only and will not serve time.
The script you proposed looks to do the same thing as removing the early exit from the script in /etc/network/if-up.d/ntp that was mentioned in the thread I linked to. It was also mentioned that it may be a bad idea as a flapping link could really mess with the time.
At this point, just delaying NTP by increasing the S23 to perhaps S90 might be enough to get past the delay in eth0 acquiring its IP. Suppose I could try hard coding the IP as well.
Thanks
Re: Possible Workaround...
Good point.
Hmm. You'd still be depending in dhcp to aquire the link, and that time period IMHO would be possibly too unpredictable for reliable acquisiton prior to firing up ntp.
That would remove the dhcp delay, yes, but still some time delay unpredictable outside the sequence, maybe.
Or, remove the initscript startup of ntp entirely using a sysvinit editor, and exclusively use an ifup.d script for the start of the ntpd - maybe the cleanest way, no?
--
Jai yen
Etch as a NTP Server
NTP starting before the networking is up is a packaging bug.
To fix it, read the manual: man update-rc.d
You can use that tool to reassign the startup priority of the NTP script and that should fix the problem. To be lazy, give the script a priority like '95'.
Looking in my own /etc/rc(?).d directories I see:
1. Networking is set up at boot (rcS.d)
2. NTP is NOT started in rcS.d, it is started at other runlevels (rc2.d to rc5.d). It is OK to start from rcS.d, but change the priority (see below).
The directories /etc/rc?.d contain symlinks which control what services are activated/deactivated at that runlevel. Everything in rcS.d is processed at boot, then when the runlevel has been determined (1..5) the items in that appropriate directory are processed. Debian default is runlevel 2, so items in rc2.d are processed. You'll see they all point to scripts in the /etc/init.d directory and the names begin with S (start service) or K (kill service) followed by a 2-digit (0 is 00, 1 is 01) priority code, and finally the name of the file to run in /etc/init.d.
To change an existing entry manually, use the 'mv' command.
For example, I have:
S98kdm
If I want to move 'kdm' to an even lower priority I do:
mv S98kdm s99kdm
If I want to switch kdm off for that runlevel:
mv S98kdm K98kdm
Lower priority numbers are guaranteed to be run first (yes, 00 is much more important than 99). There is no guarantee of execution order for items with the same priority, for example:
S20ssh
S20ntp
There is no guarantee that ssh will be started before ntp - which doesn't matter as long as ntp doesn't depend on ssh. In the case of your problem, you have any of a number of networking scripts (network, ifup, etc) and NTP obviously depends on them so it should have a larger priority number (lower priority) than those scripts.
There's your answer.
Thanks, pinniped - I was missing the guaranteed completion bit...
I shall now firmly apply a clue-by-four to my forehead repeatedly until properly adjusted...
--
Jai yen
DOH!
Somewhere between this and my php-syslog-ng, http://www.debianhelp.org/node/5948 I managed to screw things up. Serves me right for changing too many things at once.
I changed the priority for NTP and added the syslog2mysql as an init script and then my console screen would hang on boot with NTP as the last line. The GUI would still come up and I could logon through it but then it would also hang an shutdown.
Guess I still got lots of learn'n to do. For now I set NTP back to the original priority and removed the syslog2mysql init script. I then changed the IP from DHCP to static and that fixed the NTP timing issue.