Sunday 18 December 2016

Run a TFTP Server on Mac OS X



To upgrade firmware or upload config backup on networking devices TFTP server often comes handy. In my job I usually have access tosuch server, but in some cases when network access is limited or not available I configure a TFTP server on my laptop. For Linux see: Install and run a TFTP server

Mac OS X has a tftp server included, it's eazy to start it and do a minor configuration. First see if there are any commands related to tftp.
apropos tftp
You should get answer like this.
tftp(1) - trivial file transfer program
tftpd(8) - DARPA Internet Trivial File Transfer Pro
You can start it with launchctl
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
To confirm it’s running use netstat to check what is listening on its port, traditionally port 69.
netstat -na |grep \*.69
Should get answer like this.
udp6       0      0  *.69                   *.*
udp4       0      0  *.69                   *.*
It's a good idea to symlink the tftpboot to a folder you have full control over because OS X El Capitan has strong security via its System Integrity Protection (SIP) which makes things more difficult.
cd /private/
sudo rm -rf tftpboot
mkdir /Users/<username>/tftpboot
sudo ln -s /Users/<username>/tftpboot tftpboot
sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist

When you’re not using the TFTP server, make sure to unload the service.
sudo launchctl unload -F /System/Library/LaunchDaemons/tftp.plist
netstat -na |grep \*.69
The netstat should return nothing.

-cheers