Pages

Friday, April 18, 2014

Setting up a tftp server with Slackware

Setting up a tftp server with Slackware is an extremely easy task. Unlike most
of my articles there is no need of compiling any additional software since
everything is shipped with Slackware. So let's get started.
The first thing you need to do is to edit the inetd.conf file and comment out
the line that's starts with tftp:

# vi /etc/inetd.conf
...
# Tftp service is provided primarily for booting.  Most sites
# run this only on machines acting as "boot servers."
tftp  dgram   udp     wait    root    /usr/sbin/in.tftpd  in.tftpd -s /tftpboot -r blksize
...


Next start/restart the inetd service:

# sh /etc/rc.d/rc.inetd restart
Starting Internet super-server daemon:  /usr/sbin/inetd


For putting/getting files you need a special directory /tftpboot. Create it:

# mkdir /tftpboot

And place a file in there:

# touch /tftpboot/foo.txt

Finally connect to your tftp server:

# tftp 127.0.0.1

And get your prior created file foo.txt:

tftp> get foo.txt
tftp> quit


After quitting your tftp session you should be able to list your file:

# ls
foo.txt


As you can see getting a file is way too easy. If you need write access to your
tftp server for putting files then you need to do some reconfigurations. First
start by editing inetd.conf again:

# vi /etc/inetd.conf
...
# Tftp service is provided primarily for booting.  Most sites
# run this only on machines acting as "boot servers."
tftp  dgram   udp     wait    root    /usr/sbin/in.tftpd  in.tftpd -c -s /tftpboot -r blksize


Before the ...-s /tftpboot... put the -c option like above. Then restart your
inetd service one more time:

# sh /etc/rc.d/rc.inetd restart
Starting Internet super-server daemon:  /usr/sbin/inetd


Make sure that the directory /tftpboot is owned by the user nobody and the
group nogroup:

# chown -R nobody:nogroup /tftpboot
# ls -lah /tftpboot/
total 8.0K
drwxr-xr-x  2 nobody nogroup 4.0K Apr 18 13:45 ./
...


Finaly connect to your tftp server again:

# tftp 127.0.0.1

And put a file:

tftp> put foo.txt
tftp> quit


Next check that the file was created (or overwritten):

# ls -la /tftpboot/foo.txt
-rw-rw-rw- 1 nobody nogroup 0 Apr 18 13:51 /tftpboot/foo.txt


As you can see again: all too easy!

No comments:

Post a Comment