Difference between revisions of "TFTP"

From ArchWiki
Jump to: navigation, search
(Configuration: Merge info from Network Installation Guide.)
(16 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[[Category:HOWTOs (English)]]
+
[[Category:File Transfer Protocol]]
{{stub}}
+
The [[Wikipedia:Trivial File Transfer Protocol|Trivial File Transfer Protocol]] (TFTP) provides a minimalistic means for transferring files.  It is generally used as a part of [[PXE]] booting or for updating configuration and firmware on devices which have limited memory such as routers and printers.
  
== Introduction ==
+
This article describes how to set up a tftpd server under Arch Linux using the {{Pkg|tftp-hpa}} package.
This HOWTO describes how to set up a tftpd server under Arch Linux.
+
  
 
== Installation ==
 
== Installation ==
The first thing is to install all necessary stuff:
+
[[pacman|Install]] the package {{Pkg|tftp-hpa}} which can be found in the [[Official Repositories|official repositories]].
# pacman -S mkpxelinux  tftp-hpa dhcpcd
+
  
 
== Configuration ==
 
== Configuration ==
At first we will create a /etc/dhcpd.conf file. It has to look like this (basic dhcpd config):
+
The configuration for tftpd is in {{ic|/etc/conf.d/tftpd}}
  
  ddns-update-style interim;
+
The default configuration is:
+
#
subnet *'''your subnet'''* netmask *'''your netmask'''* {
+
  # Parameters to be passed to TFTPD
        option routers                  *'''IP of your router'''*;
+
#
        option subnet-mask              *'''your subnet again'''*;
+
TFTPD_ARGS="-l -s /srv/tftp/"
 +
 
 +
{{ic|-s /srv/tftp/}} set ftpd root directory to {{ic|/srv/tftp/}}. The directory {{ic|/srv/tftp}} is created automatically when {{Pkg|tftp-hpa}} is installed.
 +
 
 +
For systemd configuration, {{ic|/usr/lib/systemd/system/tftpd.service}} is used:
 +
 
 +
[Unit]
 +
Description=hpa's original TFTP daemon
 
   
 
   
        option domain-name              "'''here you can put your domain name if you dont have one take example.com'''";
+
[Service]
   
+
  ExecStart=/usr/sbin/in.tftpd -s /srv/tftp/
        option time-offset              -18000;    # Eastern Standard Time
+
  StandardInput=socket
        next-server *'''IP of your machine where dhcpd is running'''*;
+
  StandardOutput=inherit
        filename "pxelinux.0";
+
  StandardError=journal
   
+
        allow booting;
+
        allow bootp;
+
   
+
        range *'''the range of ip addresses your dhcpd is allow to take, example: 10.0.0.10 10.0.0.200'''*;
+
  }
+
  
Remove the ** from the config.
+
Copy the tftp unit files in {{ic|/usr/lib/systemd/system}} to {{ic|/etc/systemd/system}}; the former gets overwritten when systemd is updated. The [[systemd]] article talks in more detail about customizing unit files.
  
Run <code>mkpxelinux</code>, which will put the required boot files in <code>/var/tftpboot</code>.
+
For a complete list of parameters:
 +
$ man in.tftpd
  
~# mkpxelinux -c=/etc/mkpxelinux.conf
+
== Run ==
  
This will create all images and stuff to boot.
+
=== Systemd ===
 +
To start the daemon at boot, run:
 +
# systemctl enable tftpd.socket
  
Now we replace the kernel and the initrd.img with the newest from the install iso.
 
$ wget ftp://ftp.archlinux.org/other/0.8/i686/ftp-0.8-beta2-20070222-i686.iso
 
When the download is finished, we nearly finished.
 
# mount -o loop /where/the/iso/is/located /path/to/mount/
 
# cp /path/to/mount/isolinux/initd.img /var/tftpboot/
 
# cp /path/to/mount/isolinux/vmlinuz /var/tftpboot/
 
  
Now last config and then we can load all the stuff:
+
To start the daemon manually (You must respect this order):
  # nano /etc/hosts.allow
+
  # systemctl start tftpd.socket
Add these lines:
+
  # systemctl start tftpd.service
  tftpd: ALL
+
in.tftpd: ALL
+
  
Now do:
 
# /etc/rc.d/tftpd start
 
  
Note: The tftpd server will fail to start if you disabled ipv6 support in your kernel. You will need to edit /etc/conf.d/tftpd and add --ipv4 to the beginning of the TFTPD_ARGS string.
+
To stop the daemon manually (You must respect this order):
 +
# systemctl stop tftpd.socket
 +
# systemctl stop tftpd.service
 +
 
 +
=== Sysvinit ===
 +
To start the daemon at boot, add {{ic|tftpd}} to the {{ic|DAEMONS}} array in {{ic|/etc/[[rc.conf]]}}.
 +
 
 +
To start the daemon manually:
 +
# /etc/rc.d/tftpd start
  
And in a terminal:
+
To start the daemon without a configuration file:
  # dhcpcd
+
  # /usr/sbin/in.tftpd -l -s path/to/folder/to/export
  
Now you can start the PC you want to install.
+
== Troubleshooting ==
 +
=== tftpd startup fails if ipv6 is disabled ===
 +
If tftpd startup fails without leaving error messages, it might be because ipv6 is disabled and you are not explicitly telling tftpd not to use ipv6. You can make tftpd start by enabling ipv6 or by telling tftpd to only use ipv4, adding the '-4' switch to /etc/conf.d/tftpd
  
Good Luck!
+
{{hc|/etc/conf.d/tftpd|<nowiki>
 +
TFTPD_ARGS="-l -4 -s /srv/tftp/"
 +
</nowiki>}}

Revision as of 13:26, 14 December 2012

The Trivial File Transfer Protocol (TFTP) provides a minimalistic means for transferring files. It is generally used as a part of PXE booting or for updating configuration and firmware on devices which have limited memory such as routers and printers.

This article describes how to set up a tftpd server under Arch Linux using the tftp-hpa package.

Installation

Install the package tftp-hpa which can be found in the official repositories.

Configuration

The configuration for tftpd is in /etc/conf.d/tftpd

The default configuration is:

#
# Parameters to be passed to TFTPD
#
TFTPD_ARGS="-l -s /srv/tftp/"

-s /srv/tftp/ set ftpd root directory to /srv/tftp/. The directory /srv/tftp is created automatically when tftp-hpa is installed.

For systemd configuration, /usr/lib/systemd/system/tftpd.service is used:

[Unit]
Description=hpa's original TFTP daemon

[Service]
ExecStart=/usr/sbin/in.tftpd -s /srv/tftp/
StandardInput=socket
StandardOutput=inherit
StandardError=journal

Copy the tftp unit files in /usr/lib/systemd/system to /etc/systemd/system; the former gets overwritten when systemd is updated. The systemd article talks in more detail about customizing unit files.

For a complete list of parameters:

$ man in.tftpd

Run

Systemd

To start the daemon at boot, run:

# systemctl enable tftpd.socket


To start the daemon manually (You must respect this order):

# systemctl start tftpd.socket
# systemctl start tftpd.service


To stop the daemon manually (You must respect this order):

# systemctl stop tftpd.socket
# systemctl stop tftpd.service

Sysvinit

To start the daemon at boot, add tftpd to the DAEMONS array in /etc/rc.conf.

To start the daemon manually:

# /etc/rc.d/tftpd start

To start the daemon without a configuration file:

# /usr/sbin/in.tftpd -l -s path/to/folder/to/export

Troubleshooting

tftpd startup fails if ipv6 is disabled

If tftpd startup fails without leaving error messages, it might be because ipv6 is disabled and you are not explicitly telling tftpd not to use ipv6. You can make tftpd start by enabling ipv6 or by telling tftpd to only use ipv4, adding the '-4' switch to /etc/conf.d/tftpd

/etc/conf.d/tftpd
TFTPD_ARGS="-l -4 -s /srv/tftp/"