Using Samba to Serve Time
NTP is an extremely useful protocol, and as noted earlier, it's one of the most precise methods of setting the time on a Linux computer. Other time protocols do exist, however. One of these that deserves mention is the time server functionality that's included in the Server Message Block (SMB)/Common Internet Filesystem (CIFS) file- and printer-sharing protocols used on Microsoft networks and implemented in Linux by Samba (described in Chapter 7, File and Printer Sharing via Samba). If you run NTP on a Samba server, it may be simpler to configure Samba to serve the time rather than install NTP clients on all your Windows computers. (Samba can't set your system's time from a Windows SMB/CIFS time server, though.)
Samba's Time Serving Options
Samba's configuration file, smb.conf, is broken into several sections, most of which define particular directories you want to share with SMB/CIFS clients. The first section, though, is known as [global], and it defines global defaults and other options that don't make sense in individual shares. One of these is the time server option, which you can activate by setting the following parameter:
time server = Yes
This tells Samba to respond to time queries from SMB/CIFS clients, using the SMB/CIFS time server features. You can set this option whether or not your computer uses NTP, rdate, or some other time-setting protocol to set its own time, but it's most useful if the Samba server's time is set correctly through such a mechanism.
The SMB/CIFS time protocols aren't as precise as are those of NTP. Windows systems may vary by a second or so after being set in this way, even before their clocks begin to drift.
Configuring a Windows Client to Set Its Clock
To set the time on a Windows client, you can use the following command in a DOS prompt window:
C:\> NET TIME \\SERVER /SET /YES
In this command, SERVER is the NetBIOS name of the Samba server. You can manually type such a command to set the time much as you can use ntpdate to set the time on a Linux computer. You might want to create a Windows batch file to execute this command whenever a user logs in, though. You can do this by typing the command (without the DOS C:\> prompt) into a file (you might call it SETTIME.BAT) and copying that file to the Windows StartUp folder. This way, whenever the user boots the computer or logs in, the command will execute. Alternatively, if your network uses a domain configuration, you can include the command in your default network login script. (Because networking hasn't started when Windows executes AUTOEXEC.BAT, though, you should not include this command in that script.)
Windows 2000 and XP support NTP more directly. Specifically, the command NET TIME /SETSNTP:ntpserver should synchronize the time with the ntpserver system. There's even a full NTP server that ships with these systems, but its configuration is outside the scope of this book.