top of page
Recent Posts

How To Install TFTP Server In Red Hat Enterprise Linux 7

We might need to install and configure TFTP (Trivial File Transfer Protocol) service. TFTP has may use cases and PXE (Preboot Execution Environment) Boot is one of the Use cases. Let start.


Step1: To Install Required Packages, e.g. tftp-server

# yum install tftp tftp-server* -y

Step2: To verify the tftp server configuration files.

#  cat /usr/lib/systemd/system/tftp.service 
[Unit]
Description=Tftp Server
Requires=tftp.socket
Documentation=man:in.tftpd

[Service]
ExecStart=/usr/sbin/in.tftpd -s /var/lib/tftpboot
StandardInput=socket

[Install]
Also=tftp.socket
Note: in.tftpd can have some additional options, e.g --secure, -s : Change root directory on startup; --create, -c: Allow new files to be created; --permissive, -p: Perform no additional permissions checks.
# man in.tftpd command will be shown more options available for this.
#  cat /usr/lib/systemd/system/tftp.socket 
[Unit]
Description=Tftp Server Activation Socket

[Socket]
ListenDatagram=69

[Install]
WantedBy=sockets.target

Setp:3 To start the tftp server service

# systemctl start tftp.service
# systemctl is-active tftp.service
active

# systemctl enable tftp.service
# systemctl is-enabled tftp.service
indirect

# systemctl status tftp.service
tftp.service - Tftp Server
   Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
   Active: active (running) since Sat 2019-07-18 01:32:02 EDT; 30s ago
     Docs: man:in.tftpd
 Main PID: 5299 (in.tftpd)
    Tasks: 1
   Memory: 132.0K
   CGroup: /system.slice/tftp.service
           └─5299 /usr/sbin/in.tftpd -s /var/lib/tftpboot

Jul 18 01:32:02 utility.lab.munshibari.biz systemd[1]: Started Tftp Server.

Setp:4 To verify tftp server service from the client


# tftp -V
tftp-hpa 5.2, with readline

# tftp 192.168.122.254
tftp> verbose
Verbose mode on.
tftp> get ver.com
getting from 192.168.122.254:ver.com to ver.com [netascii]
Received 1300 bytes in 0.1 seconds [101954 bit/s]

tftp> put test.sh
putting test.sh to 192.168.122.254:test.sh [netascii]
Error code 1: File not found
Note: The test.sh file is not exist in my tftp server and and didnt set --create, -c options to create a new file in the server as well.

Once I have created that file in the tftp server and have set the permission to write. after that I can upload the file, as below:


# touch /var/lib/tftpboot/test.sh 
# chmod 777 /var/lib/tftpboot/test.sh 

# tftp -v 192.168.122.254 -c  put test.sh
Connected to 192.168.122.254 (192.168.122.254), port 69
putting test.sh to 192.168.122.254:test.sh [netascii]
Sent 289 bytes in 0.0 seconds [237712 bit/s]to

Troubleshooting:

1. If SElinux enabled with enforcing mode, we need to set SELinux boolean for the TFTP write, as below:

# setsebool -P tftp_anon_write 1
# setsebool -P tftp_home_dir 1

2. If Firewalld service is running in the system, we need to open the firewall port in the system to accept the incoming request at the TFTP server.

# firewall-cmd --zone=public --add-service=tftp --permanent
# firewall-cmd --reload

Hope this post will help.


2,946 views0 comments

Recent Posts

See All
Log In to Connect With Members
View and follow other members, leave comments & more.
bottom of page