     ĳ
                              +-+-+-+-+-+-+-+-+
       ۲|O|u|t|b|r|e|a|k|𰰰
                              +-+-+-+-+-+-+-+-+
                           Issue #1 - Page 4 of 13 
     

--------------------------------------------------------------------------------

synchronize your clock with ntp
written and produced at fwaggle labs, inc

who?
~~~~

i'm fwaggle. i'm sure you know me. if you don't, and you're reading this, you
will very soon. why? because i'm like a leech. i get under your skin. this
won't be the last time you hear from me. why? because i'm like herpes - i keep
coming back. you'll think i'm cool by the time you finish reading this. why?
well actually chances are you probably won't. unless you already do. which is
doubtful. why? because i keep asking myself these stupid ass fucking questions
that's why. you want 31 flavours? baskin robins is where your ass should be at.

why?
~~~~

ever told your friend to meet up with you at say 10, and there you are waiting
at 10:15, and he/she rocks up and says "nu-huh, it's 10 now!" - when your
chronograph (geek word for clock) clearly shows that it's 10:15?

well, given that people aren't the most accurate of animals - think of how two
computers must feel when they have a difference of opinion over the time. even
a difference of a few seconds can screw things up (differences of 30 seconds or
more can break an hybrid irc network apart permanently, until an operator
intervenes), so it'd be helpful if the clocks would stay accurate.

you think that's bad? consider this: you're one of multiple users who are
utilizing shared source code on a samba share. your clock is 5 minutes behind
another user, who's just compiled the sources. then 2 minutes later you come
along, and hit compile. your compiler looks, and the files all look up to date
(the executable/object file's date - created by the other user - is later than
the updated source code, which you just edited), so it doesn't compile your
changes. you're left tearing your hair out trying to figure out why the code
you added 2 minutes ago doesn't work.

so, we've established that time synchronization is a good idea. let's move on,
before someone gets hurt (me?).

what?
~~~~~

there are literally gazillions (yep, that's a gazillion) of time clients and
servers out there. here's a few of the unix variety:

   o daytime - returns the date in a plain text format ala: /bin/date
   o time - returns the seconds from the epoch in a binary format
   o ntpd (formerly xntpd) - a full featured network time protocol

surely there's others out there, but these are the main ones. daytime and time
are bot inaccurate (only accurate to a second i believe) and somewhat outdated.
they're both incorporated into the internet superserver (inetd) on almost all
unix boxen, but most modern distributions disable them by default (they can be
used in certain exploits, and let's face it - the less running services, the
better).

in this article, we're going to be discussing ntpd - or more correctly - the
network time protocol system. it's an all-in-one time solution, including time
server, time client, as well as a balancing/comparing/averaging/skew detecting
time management system.

what's so good about it? well basically it does everything a time daemon could
ever hope to do. it's the absolute best way to ensure that your clock stays
smack on the tick right.

where?
~~~~~~

the ntp homepage really has all the information you'll need, as well as a
download of the actual package AND as if that wasn't enough - there's links
to a bunch of other great time software for windows for example!

the url is: http://www.eecis.udel.edu/~ntp/index.html

installation is really simple. download, untar/gz, ./configure, then make and
make install. simple routine really.

now, you can use ntp for a lot more than what i'm going to explain - in fact,
i'm only touching the tip of the ice berg. the fact of the matter is that i
don't need to make use of all the features ntp has to offer. because of this,
and the fact that i'm FAR too lazy to do any actual research, i've decided to
just make this a primer - if you want to know more, then read the fucking
manual. ;)

how?
~~~~

once you have ntp installed, simply edit it's configuration file (usually
/etc/ntp.conf). mine simply looks like this:

server 127.127.1.0 prefer
driftfile /etc/ntp.drift

then, start ntpd by typing "ntpd". now, i don't use ntpd to synchronize my
timeservers clock, i just use it to provide the ntp service to my other
machines. i use a crontab with the following script to keep my timeservers'
clock in check:

0 0 * * * /usr/sbin/ntpdate [ip] >/dev/null 2>&1

the ip address is of a public timeserver which is as close to you as possible
(in terms of both geographic location and network routing) and in the same
timezone as you. 

now, before you go running off and picking a timeserver - read for a minute.
there are two heirachial levels of time servers: stratum 1 and stratum 2.
stratum 1 servers are fewer, and feed stratum 2 servers - and they're under an
awful ammount of load. NEVER use a stratum 1 server unless your a bigtime
public timeserver admin (ie, the admin of a stratum 2 server).

stratum 2 servers feed off of stratum 1 servers, and feed other servers. of
course, the best solution is to use your ISP's ntp server - IF they offer it.
if they don't email them and bug them to - they should. it would cut down on
load on the stratum 2 servers. a lot of isp's won't, for whatever reason (the
jackasses), so if they don't, then grab a nearby stratum 2 server from this
list:

http://www.eecis.udel.edu/~mills/ntp/clock2.htm

windows?
~~~~~~~~

of course, for unix boxen it would be a simple matter to copy the cron job and
change the upstream timeserver's ip to your LAN's timeserver's ip.. but what
about windows boxen?

well it just so happens that there's a win32 port of ntpdate! yep, and it's
great (especially if you want a completely hidden network update daemon). you
can download it here:

http://home.att.net/~Tom.Horsley/ntptime.exe
http://home.att.net/~Tom.Horsley/ntptime.cpl

ntptime.exe has no arguments at all, so you might wanna grab ntptime.cpl as
well, and copy it to your windows\system directory, then go into control panel
and use it to configure ntptime. ntptime in amazingly easy to set up - in fact
there's only about four options.

because windows lacks crond, you can set ntptime to repeatedly set the clock
(i like to make it do it every 24 hours) and an entry in startup, the run
registry key, or in the win.ini takes care of starting it up. there's no tray
icons, and once you're done configuring it you can remove the control panel
icon to stop people from meddling with it. don't forget to use the ip address
of your windows box, to save traffic on the upstream servers!

what now?
~~~~~~~~~

well.. if all goes well, you should have a perfectly harmonious working
environment, with all clocks set pretty damn close to each other. no more
bickering over what time it is!

fwaggle
http://fwaggle.net/

