Howto Start TFTP server on macOS
macOS
has built in TFTP
daemon - which is useful for developer to transfer firmware during development. Ex. if you are OpenWrt developer :)
Daemon location: /System/Library/LaunchDaemons/tftp.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>com.apple.tftpd</string>
<key>ProgramArguments</key>
<array>
<string>/usr/libexec/tftpd</string>
<string>-i</string>
<string>/private/tftpboot</string>
</array>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<true/>
</dict>
<key>InitGroups</key>
<true/>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockServiceName</key>
<string>tftp</string>
<key>SockType</key>
<string>dgram</string>
</dict>
</dict>
</dict>
</plist>
Modify TFTP service parameters
By default, TFTP folder is /private/tftpboot
- feel free to use other folder. However, remember to chmod
whole folder or added files with correct permission, else TFTP client can't get that file.
# chmod whole folder to 777
sudo chmod -R 777 /private/tftpboot
# add a file and also chmod 777
cp fw.bin /private/tftpboot
chmod 777 /private/tftpboot/fw.bin
Start and Stop daemon
Start daemon:
sudo launchctl load -F /System/Library/LaunchDaemons/tftp.plist
Stop daemon:
sudo launchctl unload /System/Library/LaunchDaemons/tftp.plist
Test with tftp
## Fetch file fw.bin
tftp -e 127.0.0.1
tftp> get fw.bin
Received 4979 bytes in 0.0 seconds
## In case file is not available
get fw.bin
Error code 256: File not found
Good luck!