Monday, May 30, 2005

How to enable TFTP service on Windows 2000 / 2003 Server

Copy the tftpd.exe file from \%systemroot%\system32\dllcache to \%systemroot%\system32.

Then, use the Microsoft Windows 2000 Server Resource Kit's Instsrv utility to create the service as follows.
instsrv tftpd c:\winnt\system32\tftpd.exe

To start the service, enter
net start tftpd

You have now created a TFTPD server on Win2K. To test the server, enter
tftp -i put

The service will create a directory named tftpdroot in \%SystemDrive%, and the file whose name you entered above will be in this directory. This is where the first issue arose. We already had an existing data directory that needed to be available via tftp, and we do not serve any content off the system drives of any servers – it is both a security and common sense issue. Therefore, the service needed to be configurable.

Because this isn’t a supported service, finding documentation on it wasn’t going to be easy, and after a few minutes with Google, I determined I’d have to create my own documentation. Since it only makes sense that a Microsoft application would look to the registry for configuration data, I grabbed my copy of RegMon, the free registry monitor from Systernals, and got busy.

After tweaking RegMon’s filter to only show the tftpd.exe process, and setting a highlight on the service’s registry key (HKLM\CurrentControlSet\Services\TFTPD), I started the service. Looking through the dozen or so highlighted registry accesses revealed the start of something good – an OpenKey attempt for this key:HKLM\CurrentControlSet\Services\TFTPD\Parameters
A quick glance in RegEdt32 showed that key didn’t exist, so let’s add it. Many Windows services have a Parameters key, so this is a good sign.

After adding the key, a stop and restart of tftpd shows a sequence of QueryValue commands – attempts to read a set of values. The values it is looking for were:
HKLM\CurrentControlSet\Services\TFTPD\Parameters\directory
HKLM\CurrentControlSet\Services\TFTPD\Parameters\clients
HKLM\CurrentControlSet\Services\TFTPD\Parameters\masters

HKLM\CurrentControlSet\Services\TFTPD\Parameters\readable
HKLM\CurrentControlSet\Services\TFTPD\Parameters\writable
BINGO! The first parameter tftpd is looking for is called directory. Let’s add a value of type REG_SZ with the value data set to “D:\tftpdata” (our tftp data directory). Following a restart of the tftpd service, we’ll retest (as described above) and we got it – the service now points to our data directory, and the file we just uploaded. Unfortunately, none of the other values are documented either, so they are probably best left alone.

Another TFTP Service available free of charge that will run on Windows is tftpd32 which can be found at http://tftp32.jounin.net/ and the following link discusses how to use it: http://thinstation.sourceforge.net/tftpd-service.html

Reference: http://www.wiredeuclid.com/modules.php?op=modload&name=News&file=article&sid=10

No comments: