Troubleshooting TFTP Timeout Issues in Ubuntu: Configuration and Debugging Guide


2 views

When working with embedded Linux systems through a VirtualBox VM running Ubuntu 12.04, I encountered persistent TFTP transfer timeouts despite successful initial connections. The problem manifested after running a Texas Instruments configuration script that potentially altered my tftpd-hpa setup.

The key symptoms included:

  • Successful connection establishment (status command works)
  • Timeout during file transfer (get zImage fails)
  • Identical behavior for both existing and non-existent files
  • Service requires restart after each VM reboot

Current /etc/default/tftpd-hpa configuration:

# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

And /etc/xinetd.d/tftp contents:

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /var/lib/tftpboot
disable = no
}

1. Verify File Permissions:

sudo chmod -R 777 /var/lib/tftpboot
sudo chown -R nobody:nogroup /var/lib/tftpboot

2. Check Firewall Rules:

sudo iptables -L
sudo ufw status

Temporarily disable firewall for testing:

sudo ufw disable

3. Test with Verbose Mode:

tftp> verbose
tftp> trace
tftp> get zImage

4. Alternative Configuration Approach:
Try running tftpd in standalone mode instead of through xinetd by modifying /etc/default/tftpd-hpa:

TFTP_OPTIONS="--secure --verbose --address 0.0.0.0:69"

Then restart the service:

sudo service tftpd-hpa restart

For VirtualBox networking:

VBoxManage modifyvm "VM name" --natpf1 "tftp,udp,127.0.0.1,69,,69"
VBoxManage modifyvm "VM name" --natpf1 "tftp-alt,udp,127.0.0.1,8069,,8069"

Capture network traffic during TFTP operation:

sudo tcpdump -i any -n udp port 69 -w tftp_debug.pcap

Analyze the packet capture with:

tcpdump -r tftp_debug.pcap -X

Check system logs for TFTP-related messages:

sudo tail -f /var/log/syslog | grep tftp


After running a Texas Instruments shell script that potentially altered my TFTP configuration, I'm experiencing a peculiar issue where:

  • TFTP connections establish successfully (confirmed via status command)
  • All file transfers (both existing and non-existent files) time out
  • The behavior persists even when connecting to localhost (127.0.0.1)

First, let's verify the basic configuration files:

# Current /etc/default/tftpd-hpa contents
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
# /etc/xinetd.d/tftp contents
service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /var/lib/tftpboot
disable = no
}

Here's what I tried to isolate the problem:

# Check if tftpd is actually running
ps aux | grep tftpd

# Verify port listening status
sudo netstat -ulnp | grep 69

# Test with verbose output
sudo tftpd -vvv /var/lib/tftpboot

# Alternative test with different directory
sudo mkdir /tmp/tftptest
sudo chmod 777 /tmp/tftptest
sudo cp /var/lib/tftpboot/zImage /tmp/tftptest/
sudo /usr/sbin/in.tftpd -L -vvv -s /tmp/tftptest

The interaction between these components is crucial:

  • xinetd vs standalone tftpd-hpa: The system appears to have both configured
  • User permissions: The service runs as 'nobody' but needs access to files
  • Firewall considerations: Even local transfers fail, suggesting deeper issues

Here's what ultimately resolved the issue:

# Stop conflicting services
sudo service tftpd-hpa stop
sudo service xinetd stop

# Clean up old configs
sudo rm /etc/xinetd.d/tftp

# Configure tftpd-hpa properly
sudo nano /etc/default/tftpd-hpa
# Updated contents:
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure --create"

# Set proper permissions
sudo chown -R tftp:tftp /var/lib/tftpboot
sudo chmod -R 777 /var/lib/tftpboot

# Restart with new config
sudo service tftpd-hpa restart

After implementing the solution, test with:

tftp localhost
tftp> get zImage
Received 1234567 bytes in 1.2 seconds
tftp> quit