TFTP Blocksize issue with Cisco devices – Fix!

Install simple TFTP Server on my Linux Ubunut

apt-get install tftpd-hpa

The default configuration file for tftpd-hpa is /etc/default/tftpd-hpa
I have config as below :

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
#TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_DIRECTORY="/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure --create  --blocksize 8192 -v"

The default root directory where files will be stored is /var/lib/tftpboot, Now i have changed to /tftp

mkdir /tftp
chown -R tftp /tftpboot

service tftpd-hpa restart

# /etc/init.d/tftpd-hpa status
● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa; generated)
   Active: active (running) since XXXXXXXXX BST; 9min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 11130 ExecStop=/etc/init.d/tftpd-hpa stop (code=exited, status=0/SUCCESS)
  Process: 11263 ExecStart=/etc/init.d/tftpd-hpa start (code=exited, status=0/SUCCESS)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/tftpd-hpa.service
           └─11283 /usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 --secure --create --blocksize 8192 -v /tftp

BB-SYSLOG systemd[1]: Starting LSB: HPA's tftp server...
BB-SYSLOG tftpd-hpa[11263]:  * Starting HPA's tftpd in.tftpd
BB-SYSLOG tftpd-hpa[11263]:    ...done.
BB-SYSLOG systemd[1]: Started LSB: HPA's tftp server.

Try testing TFTP from Cat 9300 - You see error not able to write to TFTP

#copy running-config tftp:
Address or name of remote host []? 10.188.194.55
Destination filename [bb-fes-01-confg]?
!.....
%Error writing tftp://10.188.194.55/bb-fes-01-confg (Timed out)!

when i do the TCPDUMP on Linux, the switch try to send files using blocksize of 8192

# tcpdump port 23 or port 69
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp40s0f0, link-type EN10MB (Ethernet), capture size 262144 bytes
BB-SWITCH.50158 > BB-SYSLOG.gstt.local.tftp:  44 WRQ "bb-fes-01-confg" octet blksize 8192

This what i found to be failing.

On switch change block size :
config t
!
ip tftp block 512
!
end

Note : from switch you able to get blocksize 8192 to transfer files to switch. from switch confif writing file to tftp having issue, so change required to blocksize to 512.

Lets try now :

#copy running-config tftp:
Address or name of remote host []? 10.188.194.55
Destination filename [bb-fes-01-confg]?
!!
19860 bytes copied in 1.507 secs (13179 bytes/sec)

# tcpdump port 23 or port 69
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp40s0f0, link-type EN10MB (Ethernet), capture size 262144 bytes
BB-FES-01.51590 > SP-PR-SYSLOG.gstt.local.tftp:  44 WRQ "bb-fes-01-confg" octet blksize 8192
BB-FES-01.54802 > SP-PR-SYSLOG.gstt.local.tftp:  44 WRQ "bb-fes-01-confg" octet blksize 8192
BB-FES-01.54677 > SP-PR-SYSLOG.gstt.local.tftp:  31 WRQ "bb-fes-01-confg" octet